Project overview

Our project tested the influence of microbial communities on plant performance and how “home advantages” and environmental pressures alter plant-microbe interactions across a resource gradient (dry, intermediate, wet soils). We used a natural elevation and precipitation gradient in a factorial design experiment where we collected soil inoculum across three sites of a watershed that increased in precipitation and elevation (henceforth called low, middle, and high elevation/precipitation sites).

We used axenically cloned model plant system (strawberry, Fragaria virginiana) grown in sterile soil, inoculated with soil slurries from each of those sites, and subjected to reciprocal water treatments imposed at three levels of watering (dry, intermediate, wet) based on the average precipitation of the inoculum home environment.

Figure 1. Inoculated strawberries in incubators

We hypothesized that plants inoculated with soil microbes would outperform non-inoculated plants across all treatments and microbes from the low elevation site would be the most beneficial for plant growth under all water conditions. In testing the “home advantage” hypothesis, we expected plants from each inoculum treatment would perform best in their familiar water environment (e.g., low-inoculum plants would grow best under dry-water conditions, high-inoculum plants would grow best under wet-water conditions).

Plant Biomass

  • ADD root/shoot graph codes here
  • Make root/shoot weight graphs:
  • Read in the raw data and pair it down to what we’re looking for.
### Pair down raw data 
# raw data import
shootrootwithcontrol<-read.csv('data/strawberries_raw_full_data.csv',header=TRUE)
shootrootwithcontrol %>% drop_na()

#### # subset everything unnecessary

shootroot_step1removal<-subset(shootrootwithcontrol,TimePoint!="T0"&TimePoint!="Control"&Type!="Control")
shootroot_final<-shootroot_step1removal %>% drop_na()
shootroot_inoc23removed<-subset(shootroot_final,Inoculation!="2"&Inoculation!="3")
shootroot_inoc23removed$Inoculation<-as.factor(shootroot_inoc23removed$Inoculation)
shootroot_inoc23removed$Inoculation<-factor(shootroot_inoc23removed$Inoculation,levels=c("Dry Inoculation","Medium Inoculation","Wet Inoculation","No Inoculation"))

shootroot_inoc23removed$Water<-as.factor(shootroot_inoc23removed$Water)
shootroot_inoc23removed$Water<-factor(shootroot_inoc23removed$Water,levels=c("Low","Medium","High"))

shootsonlywithcontrol<-subset(shootroot_inoc23removed,Type!="Root")
rootsonlywithcontrol<-subset(shootroot_inoc23removed,Type!="Shoot")

# export the final subset data
write.csv(shootsonlywithcontrol, "output/shootsonlywithcontrol.csv")
write.csv(rootsonlywithcontrol, "output/rootsonlywithcontrol.csv")
### check data normality: (yikes very very skewed)

hist(shootroot_inoc23removed$WeightGrams)


hist(shootsonlywithcontrol$WeightGrams)

hist(rootsonlywithcontrol$WeightGrams)


### check assumptions shoots (qqplot not normal)

typeIIIModelshoot<-lm(WeightGrams~Inoculation*Water,data=shootsonlywithcontrol)
plot(typeIIIModelshoot)

### check assumptions roots (qqplot not normal)

typeIIIModelroot<-lm(WeightGrams~Inoculation*Water,data=rootsonlywithcontrol)
plot(typeIIIModelroot)

Boxplot of above and belowground total biomass. This is the raw, non-normalized data for absolute dry-weight biomass in the roots and shoots.

root.shoot.biomass<-ggplot(shootroot_inoc23removed,aes(Water,WeightGrams,fill=Inoculation)) +
  geom_boxplot()+
  scale_fill_manual(values=c("coral2", "#E69F00", "#56B4E9","darkseagreen3"))+
  ylab("Weight (g)") +
  theme(
    axis.text = element_text(color='black',size=10),
    axis.title = element_text(color='black',size=12),
    axis.ticks = element_line(color='black'),
    legend.title = element_text(size=18),
    legend.key = element_rect(fill=NA),
    panel.background = element_rect(fill=NA,color='black'),
    panel.grid = element_blank(),
    plot.title=element_text(size=20,face="bold",vjust=2))+
facet_wrap(.~Type)

root.shoot.biomass

ggsave("figures/root.shoot.biomass.pdf", height=6, width=10)

#ggsave(filename = "mainfigstawberries.pdf",
      #plot = root.shoot.biomass,
      #bg = "transparent",
      #width = 10, height = 6, units = "in",
      #dpi = 600)

Stats for on the raw data for above and belowground plant biomass (not proportion). Run models linear models (Type III SS) for total root or shoot biomass
* First we will run the linear model as lm(mass ~ Inoculation * Water) * Then run post-hoc contrasts through emmeans (if significant effects observed)

#subset by roots and shoots
shootsonly<-subset(shootroot_inoc23removed,Type!="Root")
rootsonly<-subset(shootroot_inoc23removed,Type!="Shoot")

#subset each out by water treatment
shootlow<-subset(shootsonly,Water!="Medium"&Water!="High")
shootmed<-subset(shootsonly,Water!="Low"&Water!="High")
shoothigh<-subset(shootsonly,Water!="Medium"&Water!="Low")
rootlow<-subset(rootsonly,Water!="Medium"&Water!="High")
rootmed<-subset(rootsonly,Water!="Low"&Water!="High")
roothigh<-subset(rootsonly,Water!="Medium"&Water!="Low")

Table. Model for inoculation and water effects on total shoot biomass
* no signifcant effects

### SHOOTS stats without proportions
typeIIIModelshoot<-lm(WeightGrams~Inoculation*Water,data=shootsonly)
Anova(typeIIIModelshoot,type=3)
## Anova Table (Type III tests)
## 
## Response: WeightGrams
##                    Sum Sq  Df F value    Pr(>F)    
## (Intercept)       0.09728   1 22.3685 5.371e-06 ***
## Inoculation       0.01016   3  0.7790    0.5075    
## Water             0.00134   2  0.1536    0.8577    
## Inoculation:Water 0.02122   6  0.8131    0.5614    
## Residuals         0.61758 142                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#emmeans(typeIIIModelshoot,pairwise~Water|Inoculation)

Table. Model for inoculation and water effects on total roots biomass * no signifcant effects

### ROOTS stats without proportions
typeIIIModelroot<-lm(WeightGrams~Inoculation*Water,data=rootsonly)
Anova(typeIIIModelroot,type=3)
## Anova Table (Type III tests)
## 
## Response: WeightGrams
##                    Sum Sq  Df F value   Pr(>F)    
## (Intercept)       0.35521   1 35.4583 1.95e-08 ***
## Inoculation       0.02643   3  0.8794   0.4535    
## Water             0.01092   2  0.5448   0.5811    
## Inoculation:Water 0.05033   6  0.8373   0.5430    
## Residuals         1.42250 142                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#emmeans(typeIIIModelroot,pairwise~Water|Inoculation)

Biomass proportion

I believe we need to remake shootsonlywithcontrol. I don’t see it in the code above.

#View(shootsonlywithcontrol)
#View(rootsonlywithcontrol)



shootsonlywithcontrol <- shootsonlywithcontrol %>% 
       dplyr::rename("shoot_weight" = "WeightGrams")
rootsonlywithcontrol <- rootsonlywithcontrol %>% 
       dplyr::rename("root_weight" = "WeightGrams")
shootsonly_premerge<-subset(shootsonlywithcontrol,select = -c(SampleID,TimePoint,Type,SampleNotes,Water,Inoculation,Replicate,PlantNotes,SampleType,Sample_or_Control))
rootshoot_merge <- merge(shootsonly_premerge,rootsonlywithcontrol,by="PlantID")

#View(rootshoot_merge)
rootshoot_merge <-subset(rootshoot_merge, select = -c(Type,SampleNotes,PlantNotes))
rootshoot_merge$total_weight<-rootshoot_merge$shoot_weight+rootshoot_merge$root_weight
rootshoot_merge$shoot_prop_weight<-rootshoot_merge$shoot_weight/rootshoot_merge$total_weight
rootshoot_merge$root_prop_weight<-rootshoot_merge$root_weight/rootshoot_merge$total_weight

#########
### From here with rootshoot_merge, you can redo all the above to see what the data looks like

hist(rootshoot_merge$root_prop_weight)
hist(rootshoot_merge$shoot_prop_weight)

Make a graph of the proportion of root and shoot biomass. * For shoots : shoot biomass (mg) / total biomass (mg) * For roots : root biomass (mg) / total biomass (mg)

#View(rootshoot_merge)
longer_data <- rootshoot_merge %>%
  pivot_longer(shoot_prop_weight:root_prop_weight, names_to = "type", values_to = "response")

prop.biomass.plot<-ggplot(longer_data,aes(Water,response,fill=Inoculation)) +
  facet_wrap(.~type)+
  geom_boxplot(position=position_dodge())+
  
  ylab("Percent of total weight") +
  scale_fill_manual(values=c("coral2", "#E69F00", "#56B4E9","darkseagreen3"))+
  
  theme(
    axis.text = element_text(color='black',size=10),
    axis.title = element_text(color='black',size=12),
    axis.ticks = element_line(color='black'),
    legend.title = element_text(size=18),
    panel.background = element_rect(fill=NA,color='black'),
    legend.key = element_rect(fill=NA),
    panel.grid = element_blank(),
    plot.title=element_text(size=20,face="bold",vjust=2))

prop.biomass.plot

ggsave("figures/prop.biomass.plot.pdf", height=6, width=10)

#ggsave(filename = "mainfigstawberries.pdf",
      #plot = prop.biomass.plot,
      #bg = "transparent",
      #width = 10, height = 6, units = "in",
      #dpi = 600)

Run models linear models (Type III SS) for proportion of total biomass as shoots and roots * First we will run the linear model as lm(prop mass ~ Inoculation * Water) * Then run post-hoc contrasts through emmeans

Table. Model and post-hocs for inoculation and water effects on proportion of shoot biomass
* Effect of inoculation and water

typeIIIModelshootprop<-lm(shoot_prop_weight~Inoculation*Water,data=rootshoot_merge)
Anova(typeIIIModelshootprop,type=3)
## Anova Table (Type III tests)
## 
## Response: shoot_prop_weight
##                    Sum Sq  Df  F value    Pr(>F)    
## (Intercept)       1.70035   1 302.5713 < 2.2e-16 ***
## Inoculation       0.09143   3   5.4235  0.001465 ** 
## Water             0.04087   2   3.6359  0.028844 *  
## Inoculation:Water 0.03928   6   1.1649  0.328493    
## Residuals         0.79799 142                       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
typeIIIModelshootpropem<-emmeans(typeIIIModelshootprop,pairwise~Inoculation|Water)

#posthoc with letters
multcomp::cld(typeIIIModelshootpropem, Letters=letters)
## I bet you wanted to call this with just object[[1]] - use '[[]]' or which' if I'm wrong.
## See '? emm_list' for more information
## Water = Low:
##  Inoculation        emmean     SE  df lower.CL upper.CL .group
##  Wet Inoculation     0.322 0.0208 142    0.281    0.363  a    
##  Medium Inoculation  0.333 0.0216 142    0.291    0.376  a    
##  Dry Inoculation     0.349 0.0200 142    0.309    0.388  a    
##  No Inoculation      0.439 0.0237 142    0.393    0.486   b   
## 
## Water = Medium:
##  Inoculation        emmean     SE  df lower.CL upper.CL .group
##  Wet Inoculation     0.322 0.0200 142    0.283    0.362  a    
##  Medium Inoculation  0.377 0.0200 142    0.337    0.417  ab   
##  Dry Inoculation     0.420 0.0200 142    0.380    0.459   b   
##  No Inoculation      0.422 0.0226 142    0.377    0.467   b   
## 
## Water = High:
##  Inoculation        emmean     SE  df lower.CL upper.CL .group
##  Wet Inoculation     0.363 0.0226 142    0.318    0.407  a    
##  Medium Inoculation  0.391 0.0200 142    0.352    0.431  a    
##  Dry Inoculation     0.409 0.0208 142    0.368    0.450  a    
##  No Inoculation      0.497 0.0200 142    0.458    0.537   b   
## 
## Confidence level used: 0.95 
## P value adjustment: tukey method for comparing a family of 4 estimates 
## significance level used: alpha = 0.05 
## NOTE: If two or more means share the same grouping letter,
##       then we cannot show them to be different.
##       But we also did not show them to be the same.

Table. Model and post-hocs for inoculation and water effects on proportion of root biomass
* Effect of inoculation and water

typeIIIModelrootprop<-lm(root_prop_weight~Inoculation*Water,data=rootshoot_merge)
Anova(typeIIIModelrootprop,type=3)
## Anova Table (Type III tests)
## 
## Response: root_prop_weight
##                   Sum Sq  Df   F value    Pr(>F)    
## (Intercept)       5.9423   1 1057.4075 < 2.2e-16 ***
## Inoculation       0.0914   3    5.4235  0.001465 ** 
## Water             0.0409   2    3.6359  0.028844 *  
## Inoculation:Water 0.0393   6    1.1649  0.328493    
## Residuals         0.7980 142                        
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
typeIIIModelrootpropem<-emmeans(typeIIIModelrootprop,pairwise~Inoculation|Water)

#posthoc with letters
multcomp::cld(typeIIIModelrootpropem, Letters=letters)
## I bet you wanted to call this with just object[[1]] - use '[[]]' or which' if I'm wrong.
## See '? emm_list' for more information
## Water = Low:
##  Inoculation        emmean     SE  df lower.CL upper.CL .group
##  No Inoculation      0.561 0.0237 142    0.514    0.607  a    
##  Dry Inoculation     0.651 0.0200 142    0.612    0.691   b   
##  Medium Inoculation  0.667 0.0216 142    0.624    0.709   b   
##  Wet Inoculation     0.678 0.0208 142    0.637    0.719   b   
## 
## Water = Medium:
##  Inoculation        emmean     SE  df lower.CL upper.CL .group
##  No Inoculation      0.578 0.0226 142    0.533    0.623  a    
##  Dry Inoculation     0.580 0.0200 142    0.541    0.620  a    
##  Medium Inoculation  0.623 0.0200 142    0.583    0.663  ab   
##  Wet Inoculation     0.678 0.0200 142    0.638    0.717   b   
## 
## Water = High:
##  Inoculation        emmean     SE  df lower.CL upper.CL .group
##  No Inoculation      0.503 0.0200 142    0.463    0.542  a    
##  Dry Inoculation     0.591 0.0208 142    0.550    0.632   b   
##  Medium Inoculation  0.609 0.0200 142    0.569    0.648   b   
##  Wet Inoculation     0.637 0.0226 142    0.593    0.682   b   
## 
## Confidence level used: 0.95 
## P value adjustment: tukey method for comparing a family of 4 estimates 
## significance level used: alpha = 0.05 
## NOTE: If two or more means share the same grouping letter,
##       then we cannot show them to be different.
##       But we also did not show them to be the same.

Plant mortality

Make a plot of mortality data.

### final mortality data here
mortality_prop_data<-mortality.sheet %>%
  dplyr::group_by(Water, Inoculation) %>% 
  dplyr::summarize(prop = sum(mortality=="alive") / n())
## `summarise()` has grouped output by 'Water'. You can override using the
## `.groups` argument.
mortality_prop_data$Water<-factor(mortality_prop_data$Water,levels=c("Low","Medium","High"))

mortality_prop_data$Inoculation<-factor(mortality_prop_data$Inoculation,levels=c("Dry","Medium","Wet","None"))

# write the final file
write.csv(mortality_prop_data, "output/mortality_prop_data.csv")

### plot it
mortality<-ggplot(mortality_prop_data,aes(Inoculation,prop,fill=Inoculation))+
  geom_bar(stat="identity")+
  facet_wrap(.~Water)+
  ylab("% Survival") +
  scale_fill_manual(values=c("coral2", "#E69F00", "#56B4E9","darkseagreen3"))+ 
  theme(
    axis.text = element_text(color='black',size=10),
    axis.title = element_text(color='black',size=12),
    axis.ticks = element_line(color='black'),
    legend.title = element_text(size=18),
    legend.key = element_rect(fill=NA),
    panel.background = element_rect(fill=NA,color='black'),
    panel.grid = element_blank(),
    plot.title=element_text(size=20,face="bold",vjust=2))

mortality

ggsave("figures/mortality.pdf", height=6, width=10)

#ggsave(filename = "mortality.pdf",
      #plot = mortality,
      #bg = "transparent",
      #width = 10, height = 6, units = "in",
      #dpi = 600)

Fix ASV table and taxonomy for mctoolsr into one dataframe. Strawberries Map is already made.

#setwd("~/Desktop/Strawberries/Data for microbiome analysis/")
#ASV_table<-read.csv('asv_table.csv',header=FALSE)
#ASV_table_transpose<-t(ASV_table)
#library(janitor)
#ASV_table_transpose<-janitor::row_to_names(ASV_table_transpose,row_number = 1)
#taxonomy<-read.csv('taxonomy_table.csv',header=TRUE)
#library(dplyr)
#taxonomy <- taxonomy %>% 
       #rename("#OTU ID" = "X")
#taxonomy <- subset(taxonomy,select=-c(X.1,X.2))

#library(tidyr)
#taxonomy<-unite(taxonomy, col='taxonomy', c('Kingdom', 'Phylum', 'Class', 'Order', 'Family', 'Genus', 'Species'), sep=';')
#ASV_table_mctoolsr <- merge(ASV_table_transpose,taxonomy,by="#OTU ID")
#write.csv(ASV_table_mctoolsr,'ASV_table_mctoolsr.csv')

Make sure to change the csv file to a .txt file. I think it’s easier to just do in excel, but you can also save out the file as a .txt file. I also like to check the formatting there too to make sure it all worked out.

Next, input the data in mctoolsr. Kacie already decontamed, so no need to that. But we will need to remove low abundance ASVs and samples.

inputraw <- load_taxa_table("data/ASV_table_mctoolsr.txt", "data/strawberries_raw_full_data.txt")
#remove low abundance ASVs 
#asvsums <- rowSums(input$data_loaded)
#summary(asvsums)
#sum(asvsums==0)
#sort(asvsums)[sum(asvsums==1)]
#sum(asvsums==1)
#tail(sort(asvsums),5)
#head(sort(asvsums),5)
#remove low abundance Samples 
#sampsums <- colSums(input$data_loaded)
#summary(sampsums)
#sum(sampsums==0)
#tail(sort(sampsums),5)
#sum(sampsums<max(sampsums)/10)
#newmax <- tail(sort(sampsums))[2]
#sum(sampsums<newmax/10)
#sum(sampsums<1000)
#sort(sampsums<1000)

From this, let’s remove ASV1964, ASV1965, ASV1966, and ASV 1968. Then let’s remove the 88 samples with less than 1000 reads.

#input$data_loaded<-input$data_loaded[c(1:1957),]
#transformed<-t(input$data_loaded)
#transformedremoved<-subset(transformed,rowSums(transformed)>1000)
#input$data_loaded<-t(transformedremoved)
#input$map_loaded<-subset(input$map_loaded,rowSums(transformed)>1000)
#input$taxonomy_loaded<-input$taxonomy_loaded[c(1:1957),]

For some reason, once you mess with the dataframe, you can’t go back. So we need to download these as csvs, change them to .txt and then re-merge them and download the dataframe again. Very annoying, but hopefully it will be easy to folow:

#write.csv(input$data_loaded,'output/data_loaded_strawberries.csv')
#write.csv(input$map_loaded,'output/map_loaded_strawberries.csv')
#write.csv(input$taxonomy_loaded,'output/taxonomy_loaded_strawberries.csv')

Read in data and taxonomy

#table<-read.csv('data_loaded_strawberries.csv', header=TRUE)
#taxonomy<-read.csv('taxonomy_loaded_strawberries.csv', header=TRUE)
#library(tidyr)
#taxonomy<-unite(taxonomy, col='taxonomy', c('taxonomy1', 'taxonomy2', 'taxonomy3', 'taxonomy4', 'taxonomy5', 'taxonomy6', 'taxonomy7'), sep=';')
#ASV_table_postfiltering <- merge(table,taxonomy,by="X.OTU.ID")
#write.csv(ASV_table_postfiltering,'ASV_table_postfiltering.csv')

On your computer turn both the map and ASV table with taxonomy into text files. Make sure to rename as “#OTU ID”. Re input these and then we are good to go.

input <- load_taxa_table("data/ASV_table_postfiltering.txt", "data/map_loaded_strawberries.txt")

Then let’s start with just looking at the basic NMDS plot between the inoculations after the stress. Let’s do a lot of filtering first.

#keep only time point1
inputtimepoint1only = filter_data(input, 'TimePoint', keep_vals = 'T1')
#remove inoculum that we're not using
inputstep2 =filter_data(inputtimepoint1only, 'Inoculation', filter_vals = '2')
inputstep3 =filter_data(inputstep2, 'Inoculation', filter_vals = '3')
#Let's separate into roots and shoots
roots_post_stress = filter_data(inputstep3, 'Type', keep_vals = 'Root')
shoots_post_stress = filter_data(inputstep3, 'Type', keep_vals = 'Shoot')

Hellinger Transformation only works after you’ve filterd the samples you want (not sure why!). But be sure to filter first and then do the transformation

#using pack: labdsv

otuTAB<-roots_post_stress$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)

roots_post_stress$data_loaded<-t(hell)
otuTAB<-shoots_post_stress$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)

shoots_post_stress$data_loaded<-t(hell)

Finally it is NMDS time yay! Permanova first

#shoots first
#you need to first load the data and make it a data frame. Then transpose the data frame. Add the map loaded too
otuTAB<-shoots_post_stress$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
mta<-shoots_post_stress$map_loaded
#do as factor
mta$Water <- as.factor(mta$Water)
mta$Inoculation <- as.factor(mta$Inoculation)

## using vegan
#make the model
model1<-adonis2(otuTABtranspose~Water*Inoculation,data=mta,permutations=999,method="bray")
model1
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Permutation: free
## Number of permutations: 999
## 
## adonis2(formula = otuTABtranspose ~ Water * Inoculation, data = mta, permutations = 999, method = "bray")
##                    Df SumOfSqs      R2       F Pr(>F)    
## Water               2    4.544 0.08917  8.5359  0.001 ***
## Inoculation         3   10.005 0.19633 12.5299  0.001 ***
## Water:Inoculation   6    2.075 0.04073  1.2996  0.014 *  
## Residual          129   34.334 0.67377                   
## Total             140   50.958 1.00000                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
mtapairwise<-unite(mta,c='water_inoculation',c('Water','Inoculation'),sep='-')
#use pack pairwiseAdonis

pair.mod<-pairwise.adonis(otuTABtranspose,factors=mtapairwise$water_inoculation)
pair.mod
##         pairs Df SumsOfSqs   F.Model         R2 p.value p.adjusted sig
## 1  1-1 vs 1-4  1 1.5191273  5.603370 0.21885283   0.001      0.066    
## 2  1-1 vs 1-5  1 1.9053279  7.217850 0.24703563   0.001      0.066    
## 3  1-1 vs 1-6  1 2.1762841  9.571886 0.31309440   0.001      0.066    
## 4  1-1 vs 2-1  1 0.7305843  2.381915 0.09028591   0.002      0.132    
## 5  1-1 vs 2-4  1 1.8453148  6.287783 0.20760128   0.001      0.066    
## 6  1-1 vs 2-5  1 2.7672913 11.599113 0.31692334   0.001      0.066    
## 7  1-1 vs 2-6  1 2.7707576 13.612197 0.38223413   0.001      0.066    
## 8  1-1 vs 3-1  1 0.4729345  1.616441 0.06566510   0.043      1.000    
## 9  1-1 vs 3-4  1 1.5938847  4.940932 0.17072472   0.001      0.066    
## 10 1-1 vs 3-5  1 2.0177059  7.651480 0.26705357   0.001      0.066    
## 11 1-1 vs 3-6  1 2.1857717  8.790343 0.27650985   0.001      0.066    
## 12 1-4 vs 1-5  1 1.0713839  4.034046 0.18308241   0.001      0.066    
## 13 1-4 vs 1-6  1 1.0966567  4.974556 0.22637799   0.001      0.066    
## 14 1-4 vs 2-1  1 1.4093535  4.449831 0.18199844   0.001      0.066    
## 15 1-4 vs 2-4  1 1.3957732  4.639795 0.18830494   0.001      0.066    
## 16 1-4 vs 2-5  1 1.9271556  8.196434 0.28073407   0.001      0.066    
## 17 1-4 vs 2-6  1 1.7957404  9.365846 0.34224579   0.001      0.066    
## 18 1-4 vs 3-1  1 1.6123289  5.372181 0.22042267   0.001      0.066    
## 19 1-4 vs 3-4  1 0.9307157  2.771964 0.12172704   0.001      0.066    
## 20 1-4 vs 3-5  1 1.3223311  4.983480 0.22669206   0.001      0.066    
## 21 1-4 vs 3-6  1 1.2366843  5.007685 0.20858674   0.001      0.066    
## 22 1-5 vs 1-6  1 0.6939399  3.190181 0.14376542   0.002      0.132    
## 23 1-5 vs 2-1  1 1.6625991  5.443309 0.19834740   0.001      0.066    
## 24 1-5 vs 2-4  1 1.9221968  6.605719 0.23092301   0.001      0.066    
## 25 1-5 vs 2-5  1 1.1260662  4.865778 0.17461482   0.001      0.066    
## 26 1-5 vs 2-6  1 1.3526563  7.051627 0.26067293   0.001      0.066    
## 27 1-5 vs 3-1  1 1.9718414  6.802099 0.24466133   0.001      0.066    
## 28 1-5 vs 3-4  1 1.5609122  4.836320 0.18021547   0.001      0.066    
## 29 1-5 vs 3-5  1 0.6338939  2.459926 0.11462883   0.002      0.132    
## 30 1-5 vs 3-6  1 0.8251223  3.412662 0.13979065   0.002      0.132    
## 31 1-6 vs 2-1  1 2.0473430  7.560316 0.26471402   0.001      0.066    
## 32 1-6 vs 2-4  1 2.3467854  9.179181 0.30415607   0.001      0.066    
## 33 1-6 vs 2-5  1 1.8900397  9.692605 0.30583176   0.001      0.066    
## 34 1-6 vs 2-6  1 0.9418871  6.383160 0.25147224   0.001      0.066    
## 35 1-6 vs 3-1  1 2.3527216  9.308865 0.31761260   0.001      0.066    
## 36 1-6 vs 3-4  1 1.8780059  6.499768 0.23635718   0.001      0.066    
## 37 1-6 vs 3-5  1 1.3582537  6.328510 0.26012733   0.001      0.066    
## 38 1-6 vs 3-6  1 0.5782252  2.859245 0.12508045   0.001      0.066    
## 39 2-1 vs 2-4  1 0.9144050  2.758507 0.10308897   0.001      0.066    
## 40 2-1 vs 2-5  1 1.5039750  5.467674 0.17945820   0.001      0.066    
## 41 2-1 vs 2-6  1 1.7168980  7.007340 0.24157126   0.001      0.066    
## 42 2-1 vs 3-1  1 0.5610725  1.688759 0.06840196   0.041      1.000    
## 43 2-1 vs 3-4  1 1.2554047  3.481461 0.12668399   0.001      0.066    
## 44 2-1 vs 3-5  1 1.4495568  4.719523 0.18349964   0.001      0.066    
## 45 2-1 vs 3-6  1 1.7268551  5.989415 0.20660695   0.001      0.066    
## 46 2-4 vs 2-5  1 0.9860015  3.758324 0.13068648   0.001      0.066    
## 47 2-4 vs 2-6  1 1.2285542  5.328451 0.19497814   0.001      0.066    
## 48 2-4 vs 3-1  1 1.6679562  5.238253 0.18550202   0.001      0.066    
## 49 2-4 vs 3-4  1 0.9240982  2.660409 0.09978875   0.002      0.132    
## 50 2-4 vs 3-5  1 1.5788668  5.407019 0.20475688   0.001      0.066    
## 51 2-4 vs 3-6  1 1.9199388  6.994393 0.23319003   0.001      0.066    
## 52 2-5 vs 2-6  1 0.7311482  4.211002 0.15475366   0.001      0.066    
## 53 2-5 vs 3-1  1 2.5877375  9.945441 0.29298312   0.001      0.066    
## 54 2-5 vs 3-4  1 2.0000443  6.889613 0.21604568   0.001      0.066    
## 55 2-5 vs 3-5  1 0.7635836  3.324473 0.13127510   0.004      0.264    
## 56 2-5 vs 3-6  1 1.5431179  7.075219 0.22768042   0.001      0.066    
## 57 2-6 vs 3-1  1 2.6019765 11.483444 0.35351682   0.001      0.066    
## 58 2-6 vs 3-4  1 2.0806747  7.931725 0.26499391   0.001      0.066    
## 59 2-6 vs 3-5  1 1.3925380  7.418063 0.28079511   0.001      0.066    
## 60 2-6 vs 3-6  1 0.7588047  4.251473 0.16836535   0.001      0.066    
## 61 3-1 vs 3-4  1 1.3747237  3.941343 0.14629349   0.001      0.066    
## 62 3-1 vs 3-5  1 1.8032744  6.199031 0.23661300   0.001      0.066    
## 63 3-1 vs 3-6  1 1.8558763  6.805693 0.23626209   0.001      0.066    
## 64 3-4 vs 3-5  1 1.2787673  3.931359 0.15768731   0.001      0.066    
## 65 3-4 vs 3-6  1 1.2889708  4.227879 0.15527756   0.001      0.066    
## 66 3-5 vs 3-6  1 0.8339871  3.469362 0.14782514   0.001      0.066
#roots second
#you need to first load the data and make it a data frame. Then transpose the data frame. Add the map loaded too
otuTAB<-roots_post_stress$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
mta<-roots_post_stress$map_loaded
#do as factor
mta$Water <- as.factor(mta$Water)
mta$Inoculation <- as.factor(mta$Inoculation)

#make the model
model1<-adonis2(otuTABtranspose~Water*Inoculation,data=mta,permutations=999,method="bray")
model1
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Permutation: free
## Number of permutations: 999
## 
## adonis2(formula = otuTABtranspose ~ Water * Inoculation, data = mta, permutations = 999, method = "bray")
##                    Df SumOfSqs      R2       F Pr(>F)    
## Water               2    1.965 0.03785  4.9311  0.001 ***
## Inoculation         3   21.907 0.42198 36.6478  0.001 ***
## Water:Inoculation   6    1.940 0.03736  1.6225  0.005 ** 
## Residual          131   26.102 0.50280                   
## Total             142   51.913 1.00000                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
mtapairwise<-unite(mta,c='water_inoculation',c('Water','Inoculation'),sep='-')
pair.mod<-pairwise.adonis(otuTABtranspose,factors=mtapairwise$water_inoculation)
pair.mod
##         pairs Df SumsOfSqs    F.Model         R2 p.value p.adjusted sig
## 1  1-1 vs 1-4  1 2.3304709 10.7520273 0.33862491   0.001      0.066    
## 2  1-1 vs 1-5  1 2.7257842 13.9958194 0.38881791   0.001      0.066    
## 3  1-1 vs 1-6  1 2.9935415 18.4961485 0.45673846   0.001      0.066    
## 4  1-1 vs 2-1  1 0.4031683  1.8091573 0.06748281   0.006      0.396    
## 5  1-1 vs 2-4  1 2.8726446 12.6256092 0.34472080   0.001      0.066    
## 6  1-1 vs 2-5  1 3.2900428 16.2202363 0.40328546   0.001      0.066    
## 7  1-1 vs 2-6  1 3.2108169 17.6928017 0.43478947   0.001      0.066    
## 8  1-1 vs 3-1  1 0.4455288  1.9701797 0.07305030   0.001      0.066    
## 9  1-1 vs 3-4  1 3.1644831 13.3838201 0.33983042   0.001      0.066    
## 10 1-1 vs 3-5  1 2.9945237 13.6378410 0.37223375   0.001      0.066    
## 11 1-1 vs 3-6  1 3.5085564 19.6041591 0.42987656   0.001      0.066    
## 12 1-4 vs 1-5  1 1.6155381  8.4200524 0.33123663   0.001      0.066    
## 13 1-4 vs 1-6  1 2.0378359 13.6512652 0.44537363   0.001      0.066    
## 14 1-4 vs 2-1  1 2.4946334 10.9694804 0.35420292   0.001      0.066    
## 15 1-4 vs 2-4  1 0.6828956  2.9238116 0.13336238   0.001      0.066    
## 16 1-4 vs 2-5  1 2.1582289 10.6644150 0.35950195   0.001      0.066    
## 17 1-4 vs 2-6  1 2.1686295 12.3880557 0.40766200   0.001      0.066    
## 18 1-4 vs 3-1  1 2.4289970 10.4912876 0.34407493   0.001      0.066    
## 19 1-4 vs 3-4  1 0.7344296  3.0096255 0.12535079   0.001      0.066    
## 20 1-4 vs 3-5  1 1.9912847  8.9000016 0.33085506   0.001      0.066    
## 21 1-4 vs 3-6  1 2.2314259 12.9079363 0.38067596   0.001      0.066    
## 22 1-5 vs 1-6  1 0.9764660  7.7405356 0.30071385   0.001      0.066    
## 23 1-5 vs 2-1  1 3.0605420 15.0121826 0.41686400   0.001      0.066    
## 24 1-5 vs 2-4  1 2.8058298 13.4550518 0.40218296   0.001      0.066    
## 25 1-5 vs 2-5  1 0.5824608  3.2556788 0.13999500   0.001      0.066    
## 26 1-5 vs 2-6  1 1.2940690  8.5253874 0.30972815   0.001      0.066    
## 27 1-5 vs 3-1  1 2.9973078 14.4250997 0.40719997   0.001      0.066    
## 28 1-5 vs 3-4  1 2.7991933 12.6776881 0.36558631   0.001      0.066    
## 29 1-5 vs 3-5  1 0.5258017  2.6567778 0.12267650   0.001      0.066    
## 30 1-5 vs 3-6  1 1.3394427  8.7615930 0.28482247   0.001      0.066    
## 31 1-6 vs 2-1  1 3.4492629 20.3624733 0.49229342   0.001      0.066    
## 32 1-6 vs 2-4  1 3.3275985 19.3092040 0.49121330   0.001      0.066    
## 33 1-6 vs 2-5  1 2.1375308 14.9786899 0.42822330   0.001      0.066    
## 34 1-6 vs 2-6  1 0.5193205  4.5681287 0.19382653   0.001      0.066    
## 35 1-6 vs 3-1  1 3.3525201 19.3444273 0.47948202   0.001      0.066    
## 36 1-6 vs 3-4  1 3.3126714 17.6312329 0.44488227   0.001      0.066    
## 37 1-6 vs 3-5  1 1.8088964 11.3195449 0.37334152   0.001      0.066    
## 38 1-6 vs 3-6  1 0.6502710  5.4204457 0.19767898   0.001      0.066    
## 39 2-1 vs 2-4  1 2.8095484 11.8410957 0.33986003   0.001      0.066    
## 40 2-1 vs 2-5  1 3.2843118 15.5280751 0.40303273   0.001      0.066    
## 41 2-1 vs 2-6  1 3.3359506 17.5973237 0.44440690   0.001      0.066    
## 42 2-1 vs 3-1  1 0.2258990  0.9595659 0.03844481   0.573      1.000    
## 43 2-1 vs 3-4  1 3.1444207 12.7944897 0.33852791   0.001      0.066    
## 44 2-1 vs 3-5  1 3.0193410 13.1617923 0.37432086   0.001      0.066    
## 45 2-1 vs 3-6  1 3.7608595 20.2203393 0.44715143   0.001      0.066    
## 46 2-4 vs 2-5  1 2.9032388 13.4350596 0.37914596   0.001      0.066    
## 47 2-4 vs 2-6  1 3.0689701 15.8741325 0.43049508   0.001      0.066    
## 48 2-4 vs 3-1  1 2.6948679 11.1892530 0.32727398   0.001      0.066    
## 49 2-4 vs 3-4  1 0.4043774  1.6085339 0.06281242   0.003      0.198    
## 50 2-4 vs 3-5  1 2.7325643 11.6250297 0.35632242   0.001      0.066    
## 51 2-4 vs 3-6  1 3.5213481 18.6181870 0.43686014   0.001      0.066    
## 52 2-5 vs 2-6  1 1.6469000  9.9742666 0.32201785   0.001      0.066    
## 53 2-5 vs 3-1  1 3.3137878 15.4071400 0.40115301   0.001      0.066    
## 54 2-5 vs 3-4  1 3.0860445 13.6125700 0.36191544   0.001      0.066    
## 55 2-5 vs 3-5  1 0.3557668  1.7199923 0.07570391   0.040      1.000    
## 56 2-5 vs 3-6  1 2.0799410 12.6482231 0.34512514   0.001      0.066    
## 57 2-6 vs 3-1  1 3.3383177 17.2694923 0.43976867   0.001      0.066    
## 58 2-6 vs 3-4  1 3.2702032 15.8452732 0.40790737   0.001      0.066    
## 59 2-6 vs 3-5  1 1.5940716  8.7356618 0.30400072   0.001      0.066    
## 60 2-6 vs 3-6  1 0.3127066  2.2112476 0.08770877   0.018      1.000    
## 61 3-1 vs 3-4  1 2.9495841 11.8432873 0.32145034   0.001      0.066    
## 62 3-1 vs 3-5  1 2.9364568 12.5953741 0.36407683   0.001      0.066    
## 63 3-1 vs 3-6  1 3.5913145 18.9734204 0.43147475   0.001      0.066    
## 64 3-4 vs 3-5  1 2.7399326 11.2070820 0.32762461   0.001      0.066    
## 65 3-4 vs 3-6  1 3.5280528 17.5521805 0.40301496   0.001      0.066    
## 66 3-5 vs 3-6  1 1.7001603  9.4708487 0.29167235   0.001      0.066

Everything is significant including pairwise adonis.

Let’s make the plot:

shoot.mds<-metaMDS(t(shoots_post_stress$data_loaded))
shoot<-scores(shoot.mds)
data.scoresshoot <- as.data.frame(shoot$sites) 
data.scoresshoot$Water <- shoots_post_stress$map_loaded$Water
data.scoresshoot$Inoculation <- shoots_post_stress$map_loaded$Inoculation


root.mds<-metaMDS(t(roots_post_stress$data_loaded))
root<-scores(root.mds)
data.scoresroot <- as.data.frame(root$sites) 
data.scoresroot$Water <- roots_post_stress$map_loaded$Water
data.scoresroot$Inoculation <- roots_post_stress$map_loaded$Inoculation
b<-ggplot(data=data.scoresshoot,aes(x=NMDS1,y=NMDS2,shape=factor(Water),color=factor(Inoculation))) + 
  scale_color_manual(values=c("coral2", "#E69F00", "#56B4E9","darkseagreen3"))+ 
  ggtitle("Shoots")+
  geom_point(data=data.scoresshoot,aes(x=NMDS1,y=NMDS2,shape=factor(Water),color=factor(Inoculation))) + # add the point markers

  theme(
    axis.text = element_text(color='black',size=10),
    axis.title = element_text(color='black',size=12),
    axis.ticks = element_line(color='black'),
    legend.title = element_text(size=8),
    legend.key = element_rect(fill=NA),
    panel.background = element_rect(fill=NA,color='black'),
    panel.grid = element_blank(),
    
    plot.title=element_text(size=20,face="bold",vjust=2))


a<-ggplot(data=data.scoresroot,aes(x=NMDS1,y=NMDS2,shape=factor(Water),color=factor(Inoculation))) + 
  scale_color_manual(values=c("coral2", "#E69F00", "#56B4E9","darkseagreen3"))+ 
  ggtitle("Roots")+
  geom_point(data=data.scoresroot,aes(x=NMDS1,y=NMDS2,shape=factor(Water),color=factor(Inoculation))) + # add the point markers

  
  theme(
    axis.text = element_text(color='black',size=10),
    axis.title = element_text(color='black',size=12),
    axis.ticks = element_line(color='black'),
    legend.title = element_text(size=8),
    panel.background = element_rect(fill=NA,color='black'),
    panel.grid = element_blank(),
    legend.position = "none",
    plot.title=element_text(size=20,face="bold",vjust=2))

both_plots<-a+b
both_plots

ggsave("figures/both_plots.pdf", height=6, width=12)

#ggsave(filename = "both_plots.pdf",
      #plot = both_plots,
      #bg = "transparent",
      #width = 12, height = 6, units = "in",
      #dpi = 600)

Refilter time.

#Let's view the original input map first
#View(input$map_loaded)
#Start by removing all roots. We can only do a time one with shoots
inputshootsonly = filter_data(input, 'Type', keep_vals = 'Shoot')
## 316 samples remaining
inputshootsonlyminus2 =filter_data(inputshootsonly, 'Inoculation', filter_vals = '2')
## 255 samples remaining
inputshootsonlyminus3 =filter_data(inputshootsonlyminus2, 'Inoculation', filter_vals = '3')
## 204 samples remaining
finalNMDSmovement = filter_data(inputshootsonlyminus3, 'TimePoint', filter_vals = 'Control')
## 203 samples remaining

Then, let’s set up the data for the NMDS plot:

#View(finalNMDSmovement$map_loaded)
time.mds<-metaMDS(t(finalNMDSmovement$data_loaded))
data.time <- as.data.frame(scores(time.mds)$sites) 
data.time$Water <- finalNMDSmovement$map_loaded$Water
data.time$Inoculation <- finalNMDSmovement$map_loaded$Inoculation
data.time$TimePoint <- finalNMDSmovement$map_loaded$TimePoint
data.time$PlantID <- finalNMDSmovement$map_loaded$PlantID
#envfit
finalNMDSmovement$map_loaded<-subset(finalNMDSmovement$map_loaded, select = -c(WeightGrams,SampleNotes, PlantNotes))
finalNMDSmovement$map_loaded$Water<-as.factor(finalNMDSmovement$map_loaded$Water)
finalNMDSmovement$map_loaded$Inoculation<-as.factor(finalNMDSmovement$map_loaded$Inoculation)
finalNMDSmovement$map_loaded$TimeWater <- paste(finalNMDSmovement$map_loaded$TimePoint,finalNMDSmovement$map_loaded$Water)
finalNMDSmovement$map_loaded$TimeInoculation <- paste(finalNMDSmovement$map_loaded$TimePoint,finalNMDSmovement$map_loaded$Inoculation)

waterfinalvf <- envfit(time.mds~TimeWater, data=finalNMDSmovement$map_loaded, perm = 999)
water.scrs.final <- as.data.frame(scores(waterfinalvf, display = "factors"))

inocfinalvf <- envfit(time.mds~TimeInoculation, data=finalNMDSmovement$map_loaded, perm = 999)
inoc.scrs.final <- as.data.frame(scores(inocfinalvf, display = "factors"))
NMDS1.mean.data.time<-aggregate(NMDS1~ Water*TimePoint, data=data.time, FUN=mean)
NMDS2.mean.data.time<-aggregate(NMDS2~ Water*TimePoint, data=data.time, FUN=mean)
centroid.data.time<-as.data.frame(cbind(NMDS1.mean.data.time, NMDS2.mean.data.time[3]))


timewater<-ggplot(data=data.time,aes(x=NMDS1,y=NMDS2,color=factor(Water),shape=factor(TimePoint))) + 
  ggtitle("Water Treatment")+
  scale_color_manual(values=c("paleturquoise3", "steelblue2", "slategray4"))+
  geom_point(data=data.time,aes(x=NMDS1,y=NMDS2,color=factor(Water),shape=factor(TimePoint))) +
  geom_segment(aes(x = centroid.data.time[1,3], xend = centroid.data.time[4,3], 
                   y = centroid.data.time[1,4], yend = centroid.data.time[4,4]),
               arrow = arrow(length = unit(0.25, "cm")), colour = "paleturquoise3") +
  geom_segment(aes(x = centroid.data.time[2,3], xend = centroid.data.time[5,3], 
                   y = centroid.data.time[2,4], yend = centroid.data.time[5,4]),
               arrow = arrow(length = unit(0.25, "cm")), colour = "steelblue2") +
  geom_segment(aes(x = centroid.data.time[3,3], xend = centroid.data.time[6,3], 
                   y = centroid.data.time[3,4], yend = centroid.data.time[6,4]),
               arrow = arrow(length = unit(0.25, "cm")), colour = "slategray4") +
 
  theme(
    axis.text = element_text(color='black',size=10),
    axis.title = element_text(color='black',size=12),
    axis.ticks = element_line(color='black'),
    legend.title = element_text(size=8),
    panel.background = element_rect(fill=NA,color='black'),
    panel.grid = element_blank(),
    
    plot.title=element_text(size=20,face="bold",vjust=2))

####
NMDS1.mean.data.inoc<-aggregate(NMDS1~ Inoculation*TimePoint, data=data.time, FUN=mean)
NMDS2.mean.data.inoc<-aggregate(NMDS2~ Inoculation*TimePoint, data=data.time, FUN=mean)
centroid.data.inoc<-as.data.frame(cbind(NMDS1.mean.data.inoc, NMDS2.mean.data.inoc[3]))


timeinoculation<-ggplot(data=data.time,aes(x=NMDS1,y=NMDS2,color=factor(Inoculation),shape=factor(TimePoint))) + 
  scale_color_manual(values=c("coral2", "#E69F00", "#56B4E9","darkseagreen3"))+ 
  ggtitle("Inoculation")+
  geom_point(data=data.time,aes(x=NMDS1,y=NMDS2,color=factor(Inoculation),shape=factor(TimePoint))) + # add the point markers
  geom_segment(aes(x = centroid.data.inoc[1,3], xend = centroid.data.inoc[5,3], 
                   y = centroid.data.inoc[1,4], yend = centroid.data.inoc[5,4])
               ,arrow = arrow(length = unit(0.25, "cm")), colour = "coral2") +
  geom_segment(aes(x = centroid.data.inoc[2,3], xend = centroid.data.inoc[6,3], 
                   y = centroid.data.inoc[2,4], yend = centroid.data.inoc[6,4]),
               arrow = arrow(length = unit(0.25, "cm")), colour = "#E69F00") +
  geom_segment(aes(x = centroid.data.inoc[3,3], xend = centroid.data.inoc[7,3], 
                   y = centroid.data.inoc[3,4], yend = centroid.data.inoc[7,4]),
               arrow = arrow(length = unit(0.25, "cm")), colour = "#56B4E9") +
  geom_segment(aes(x = centroid.data.inoc[4,3], xend = centroid.data.inoc[8,3], 
                   y = centroid.data.inoc[4,4], yend = centroid.data.inoc[8,4]),
               arrow = arrow(length = unit(0.25, "cm")), colour = "darkseagreen3") +
  theme(
    axis.text = element_text(color='black',size=10),
    axis.title = element_text(color='black',size=12),
    axis.ticks = element_line(color='black'),
    legend.title = element_text(size=8),
    panel.background = element_rect(fill=NA,color='black'),
    panel.grid = element_blank(),
    
    plot.title=element_text(size=20,face="bold",vjust=2))

# use packages patchwork
both_plots_move<-timewater+timeinoculation
both_plots_move

ggsave("figures/timeinoculation.pdf", height=6, width=8)


#ggsave(filename = "timeinoculation.pdf",
      #plot = timeinoculation,
      #bg = "transparent",
      #width = 8, height = 6, units = "in",
      #dpi = 600)
#geom_path(aes(color=Trt), show.legend = F)

Let’s see if these are significant:

#shoots first
#you need to first load the data and make it a data frame. Then transpose the data frame. Add the map loaded too
otuTAB<-finalNMDSmovement$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
mta<-finalNMDSmovement$map_loaded
#do as factor
mta$Water <- as.factor(mta$Water)
mta$Inoculation <- as.factor(mta$Inoculation)
mta$TimePoint <- as.factor(mta$TimePoint)

#make the model
model1<-adonis2(otuTABtranspose~Water*TimePoint,data=mta,permutations=999,method="bray")
model1
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Permutation: free
## Number of permutations: 999
## 
## adonis2(formula = otuTABtranspose ~ Water * TimePoint, data = mta, permutations = 999, method = "bray")
##                  Df SumOfSqs      R2       F Pr(>F)    
## Water             2    3.751 0.04429  5.3510  0.001 ***
## TimePoint         1   10.177 0.12016 29.0375  0.001 ***
## Water:TimePoint   2    1.725 0.02037  2.4609  0.001 ***
## Residual        197   69.047 0.81519                   
## Total           202   84.700 1.00000                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model3<-adonis2(otuTABtranspose~Water*TimePoint,data=mta,permutations=999,method="jaccard")
model3
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Permutation: free
## Number of permutations: 999
## 
## adonis2(formula = otuTABtranspose ~ Water * TimePoint, data = mta, permutations = 999, method = "jaccard")
##                  Df SumOfSqs      R2       F Pr(>F)    
## Water             2    2.798 0.03089  3.5227  0.001 ***
## TimePoint         1    8.059 0.08895 20.2908  0.001 ***
## Water:TimePoint   2    1.500 0.01656  1.8882  0.004 ** 
## Residual        197   78.247 0.86361                   
## Total           202   90.605 1.00000                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model2<-adonis2(otuTABtranspose~Inoculation*TimePoint,data=mta,permutations=999,method="bray")
model2
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Permutation: free
## Number of permutations: 999
## 
## adonis2(formula = otuTABtranspose ~ Inoculation * TimePoint, data = mta, permutations = 999, method = "bray")
##                        Df SumOfSqs      R2       F Pr(>F)    
## Inoculation             3    6.457 0.07624  6.4819  0.001 ***
## TimePoint               1   10.447 0.12334 31.4597  0.001 ***
## Inoculation:TimePoint   3    3.041 0.03591  3.0528  0.001 ***
## Residual              195   64.754 0.76452                   
## Total                 202   84.700 1.00000                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model4<-adonis2(otuTABtranspose~Inoculation*TimePoint,data=mta,permutations=999,method="jaccard")
model4
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Permutation: free
## Number of permutations: 999
## 
## adonis2(formula = otuTABtranspose ~ Inoculation * TimePoint, data = mta, permutations = 999, method = "jaccard")
##                        Df SumOfSqs      R2       F Pr(>F)    
## Inoculation             3    4.757 0.05251  4.1159  0.001 ***
## TimePoint               1    8.226 0.09079 21.3496  0.001 ***
## Inoculation:TimePoint   3    2.490 0.02748  2.1542  0.001 ***
## Residual              195   75.131 0.82922                   
## Total                 202   90.605 1.00000                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Let’s look at T0 only

## 316 samples remaining
## 255 samples remaining
## 204 samples remaining
## 62 samples remaining

T0 Graph Only

library(ggplot2)
ggplot(data=data.time,aes(x=NMDS1,y=NMDS2,shape=factor(Water),color=factor(Inoculation))) + 
  ggtitle("T0 Shoots")+
  geom_point(data=data.time,aes(x=NMDS1,y=NMDS2,shape=factor(Water),color=factor(Inoculation))) + # add the point markers
  stat_ellipse(data=data.time,aes(x=NMDS1,y=NMDS2,shape=factor(Inoculation),color=factor(Inoculation)))+
  
  theme(
    axis.text = element_text(color='black',size=10),
    axis.title = element_text(color='black',size=12),
    axis.ticks = element_line(color='black'),
    legend.title = element_text(size=8),
    panel.background = element_rect(fill=NA,color='black'),
    panel.grid = element_blank(),
    
    plot.title=element_text(size=20,face="bold",vjust=2))

library(vegan)
#make the model
otuTAB<-finalNMDSmovement$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
mta<-finalNMDSmovement$map_loaded
#do as factor
mta$Water <- as.factor(mta$Water)
mta$Inoculation <- as.factor(mta$Inoculation)


model1<-adonis2(otuTABtranspose~Water*Inoculation,data=mta,permutations=999,method="bray")
model1
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Permutation: free
## Number of permutations: 999
## 
## adonis2(formula = otuTABtranspose ~ Water * Inoculation, data = mta, permutations = 999, method = "bray")
##                   Df SumOfSqs      R2      F Pr(>F)  
## Water              2   0.4007 0.04870 1.5865  0.049 *
## Inoculation        3   0.5896 0.07166 1.5562  0.016 *
## Water:Inoculation  6   0.9228 0.11216 1.2179  0.118  
## Residual          50   6.3145 0.76748                
## Total             61   8.2277 1.00000                
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

re-filter

## 316 samples remaining
## 255 samples remaining
## 204 samples remaining
## 203 samples remaining
## 52 samples remaining
## 54 samples remaining
## 46 samples remaining
## 51 samples remaining
NMDS1.mean.inoc1<-aggregate(NMDS1~ Water*TimePoint, data=data.scoresinoc1, FUN=mean)
NMDS2.mean.inoc1<-aggregate(NMDS2~ Water*TimePoint, data=data.scoresinoc1, FUN=mean)
centroid.inoc1<-as.data.frame(cbind(NMDS1.mean.inoc1, NMDS2.mean.inoc1[3]))

data.scoresinoc1$TimePoint<-factor(data.scoresinoc1$TimePoint,levels=c("T1","T0"))
data.scoresinoc4$TimePoint<-factor(data.scoresinoc4$TimePoint,levels=c("T1","T0"))
data.scoresinoc5$TimePoint<-factor(data.scoresinoc5$TimePoint,levels=c("T1","T0"))
data.scoresinoc6$TimePoint<-factor(data.scoresinoc6$TimePoint,levels=c("T1","T0"))

inoc1.trajectory<-ggplot(data=data.scoresinoc1,aes(x=NMDS1,y=NMDS2,shape=factor(TimePoint),color=factor(Water))) + 
  ggtitle("Inoculation 1")+
  geom_point(data=data.scoresinoc1,aes(x=NMDS1,y=NMDS2,shape=factor(TimePoint),color=factor(Water))) + 
  stat_ellipse(data=data.scoresinoc1,aes(x=NMDS1,y=NMDS2,color=factor(Water),linetype=factor(TimePoint)))+
  scale_color_manual(values=c("red", "#E69F00", "#56B4E9"))+  # for water 1,2,3
  geom_segment(aes(x = centroid.inoc1[4,3], xend = centroid.inoc1[1,3], 
                   y = centroid.inoc1[4,4], yend = centroid.inoc1[1,4]),arrow = arrow(), colour = "red") +
  geom_segment(aes(x = centroid.inoc1[5,3], xend = centroid.inoc1[2,3], 
                   y = centroid.inoc1[5,4], yend = centroid.inoc1[2,4]),arrow = arrow(), colour = "#E69F00") +
  geom_segment(aes(x = centroid.inoc1[6,3], xend = centroid.inoc1[3,3], 
                   y = centroid.inoc1[6,4], yend = centroid.inoc1[3,4]),arrow = arrow(), colour = "#56B4E9") +
  theme(
    axis.text = element_text(color='black',size=10),
    axis.title = element_text(color='black',size=12),
    axis.ticks = element_line(color='black'),
    legend.title = element_text(size=8),
    panel.background = element_rect(fill=NA,color='black'),
    panel.grid = element_blank(),
    legend.position = "none",
    plot.title=element_text(size=20,face="bold",vjust=2))
###

NMDS1.mean.inoc4<-aggregate(NMDS1~ Water*TimePoint, data=data.scoresinoc4, FUN=mean)
NMDS2.mean.inoc4<-aggregate(NMDS2~ Water*TimePoint, data=data.scoresinoc4, FUN=mean)
centroid.inoc4<-as.data.frame(cbind(NMDS1.mean.inoc4, NMDS2.mean.inoc4[3]))


data.scoresinoc4$TimePoint<-factor(data.scoresinoc4$TimePoint,levels=c("T1","T0"))
inoc4.trajectory<-ggplot(data=data.scoresinoc4,aes(x=NMDS1,y=NMDS2,shape=factor(TimePoint),color=factor(Water))) + 
  ggtitle("Inoculation 4")+
  geom_point(data=data.scoresinoc4,aes(x=NMDS1,y=NMDS2,shape=factor(TimePoint),color=factor(Water))) + 
  stat_ellipse(data=data.scoresinoc4,aes(x=NMDS1,y=NMDS2,color=factor(Water),linetype=factor(TimePoint)))+
  scale_color_manual(values=c("red", "#E69F00", "#56B4E9"))+ 
  geom_segment(aes(x = centroid.inoc4[4,3], xend = centroid.inoc4[1,3], 
                   y = centroid.inoc4[4,4], yend = centroid.inoc4[1,4]),arrow = arrow(), colour = "red") +
  geom_segment(aes(x = centroid.inoc4[5,3], xend = centroid.inoc4[2,3], 
                   y = centroid.inoc4[5,4], yend = centroid.inoc4[2,4]),arrow = arrow(), colour = "#E69F00") +
  geom_segment(aes(x = centroid.inoc4[6,3], xend = centroid.inoc4[3,3], 
                   y = centroid.inoc4[6,4], yend = centroid.inoc4[3,4]),arrow = arrow(), colour = "#56B4E9") +
  theme(
    axis.text = element_text(color='black',size=10),
    axis.title = element_text(color='black',size=12),
    axis.ticks = element_line(color='black'),
    legend.title = element_text(size=8),
    panel.background = element_rect(fill=NA,color='black'),
    panel.grid = element_blank(),
   
    plot.title=element_text(size=20,face="bold",vjust=2))

###

NMDS1.mean.inoc5<-aggregate(NMDS1~ Water*TimePoint, data=data.scoresinoc5, FUN=mean)
NMDS2.mean.inoc5<-aggregate(NMDS2~ Water*TimePoint, data=data.scoresinoc5, FUN=mean)
centroid.inoc5<-as.data.frame(cbind(NMDS1.mean.inoc5, NMDS2.mean.inoc5[3]))


data.scoresinoc5$TimePoint<-factor(data.scoresinoc5$TimePoint,levels=c("T1","T0"))
inoc5.trajectory<-ggplot(data=data.scoresinoc5,aes(x=NMDS1,y=NMDS2,shape=factor(TimePoint),color=factor(Water))) + 
  ggtitle("Inoculation 5")+
  geom_point(data=data.scoresinoc5,aes(x=NMDS1,y=NMDS2,shape=factor(TimePoint),color=factor(Water))) + 
  stat_ellipse(data=data.scoresinoc5,aes(x=NMDS1,y=NMDS2,color=factor(Water),linetype=factor(TimePoint)))+
  scale_color_manual(values=c("red", "#E69F00", "#56B4E9"))+ 
  geom_segment(aes(x = centroid.inoc5[4,3], xend = centroid.inoc5[1,3], 
                   y = centroid.inoc5[4,4], yend = centroid.inoc5[1,4]),arrow = arrow(), colour = "red") +
  geom_segment(aes(x = centroid.inoc5[5,3], xend = centroid.inoc5[2,3], 
                   y = centroid.inoc5[5,4], yend = centroid.inoc5[2,4]),arrow = arrow(), colour = "#E69F00") +
  geom_segment(aes(x = centroid.inoc5[6,3], xend = centroid.inoc5[3,3], 
                   y = centroid.inoc5[6,4], yend = centroid.inoc5[3,4]),arrow = arrow(), colour = "#56B4E9") +
  theme(
    axis.text = element_text(color='black',size=10),
    axis.title = element_text(color='black',size=12),
    axis.ticks = element_line(color='black'),
    legend.title = element_text(size=8),
    panel.background = element_rect(fill=NA,color='black'),
    panel.grid = element_blank(),
    legend.position = "none",
    plot.title=element_text(size=20,face="bold",vjust=2))

##

NMDS1.mean.inoc6<-aggregate(NMDS1~ Water*TimePoint, data=data.scoresinoc6, FUN=mean)
NMDS2.mean.inoc6<-aggregate(NMDS2~ Water*TimePoint, data=data.scoresinoc6, FUN=mean)
centroid.inoc6<-as.data.frame(cbind(NMDS1.mean.inoc6, NMDS2.mean.inoc6[3]))

data.scoresinoc6$TimePoint<-factor(data.scoresinoc6$TimePoint,levels=c("T1","T0"))

inoc6.trajectory<-ggplot(data=data.scoresinoc6,aes(x=NMDS1,y=NMDS2,shape=factor(TimePoint),color=factor(Water))) + 
  ggtitle("Inoculation 6")+
  geom_point(data=data.scoresinoc6,aes(x=NMDS1,y=NMDS2,shape=factor(TimePoint),color=factor(Water))) + 
  stat_ellipse(data=data.scoresinoc6,aes(x=NMDS1,y=NMDS2,color=factor(Water),linetype=factor(TimePoint)))+
  scale_color_manual(values=c("red", "#E69F00", "#56B4E9"))+ 
  geom_segment(aes(x = centroid.inoc6[4,3], xend = centroid.inoc6[1,3], 
                   y = centroid.inoc6[4,4], yend = centroid.inoc6[1,4]),arrow = arrow(), colour = "red") +
  geom_segment(aes(x = centroid.inoc6[5,3], xend = centroid.inoc6[2,3], 
                   y = centroid.inoc6[5,4], yend = centroid.inoc6[2,4]),arrow = arrow(), colour = "#E69F00") +
  geom_segment(aes(x = centroid.inoc6[6,3], xend = centroid.inoc6[3,3], 
                   y = centroid.inoc6[6,4], yend = centroid.inoc6[3,4]),arrow = arrow(), colour = "#56B4E9") +
  theme(
    axis.text = element_text(color='black',size=10),
    axis.title = element_text(color='black',size=12),
    axis.ticks = element_line(color='black'),
    legend.title = element_text(size=8),
    panel.background = element_rect(fill=NA,color='black'),
    panel.grid = element_blank(),
    legend.position = "none",
    plot.title=element_text(size=20,face="bold",vjust=2))


library(patchwork)
inocalone<-(inoc1.trajectory+inoc4.trajectory)/(inoc5.trajectory+inoc6.trajectory)
inocalone

inocalone

ggsave("figures/timebyinoc.pdf", height=8, width=10)

#ggsave(filename = "timebyinoc.pdf",
#      plot = inocalone,
#      bg = "transparent",
#      width = 10, height = 8, units = "in",
#      dpi = 600)

beta dispersion:

inoc1.dataframe <- as.data.frame(t(inoc1NMDSmovement$data_loaded))
groups <- inoc1NMDSmovement$map_loaded$TimePoint
disinoc1 <- vegdist(inoc1.dataframe,method="bray")
bdinoc1<-betadisper(disinoc1,groups)
anova(bdinoc1)
## Analysis of Variance Table
## 
## Response: Distances
##           Df  Sum Sq Mean Sq F value    Pr(>F)    
## Groups     1 0.32760 0.32760  32.335 6.695e-07 ***
## Residuals 50 0.50657 0.01013                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.beta.disper.results.inoc1 <- permutest(bdinoc1, pairwise = TRUE, iter=9999)
pairwise.beta.disper.results.inoc1
## 
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 999
## 
## Response: Distances
##           Df  Sum Sq Mean Sq      F N.Perm Pr(>F)    
## Groups     1 0.32760 0.32760 32.335    999  0.001 ***
## Residuals 50 0.50657 0.01013                         
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Pairwise comparisons:
## (Observed p-value below diagonal, permuted p-value above diagonal)
##            T0    T1
## T0            0.001
## T1 6.6955e-07
inoc4.dataframe <- as.data.frame(t(inoc4NMDSmovement$data_loaded))
groups <- inoc4NMDSmovement$map_loaded$TimePoint
disinoc4 <- vegdist(inoc4.dataframe,method="bray")
bdinoc4<-betadisper(disinoc4,groups)
anova(bdinoc4)
## Analysis of Variance Table
## 
## Response: Distances
##           Df  Sum Sq Mean Sq F value    Pr(>F)    
## Groups     1 0.97751 0.97751  233.49 < 2.2e-16 ***
## Residuals 52 0.21770 0.00419                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.beta.disper.results.inoc4 <- permutest(bdinoc4, pairwise = TRUE, iter=9999)
pairwise.beta.disper.results.inoc4
## 
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 999
## 
## Response: Distances
##           Df  Sum Sq Mean Sq      F N.Perm Pr(>F)    
## Groups     1 0.97751 0.97751 233.49    999  0.001 ***
## Residuals 52 0.21770 0.00419                         
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Pairwise comparisons:
## (Observed p-value below diagonal, permuted p-value above diagonal)
##            T0    T1
## T0            0.001
## T1 7.1546e-21
inoc5.dataframe <- as.data.frame(t(inoc5NMDSmovement$data_loaded))
groups <- inoc5NMDSmovement$map_loaded$TimePoint
disinoc5 <- vegdist(inoc5.dataframe,method="bray")
bdinoc5<-betadisper(disinoc5,groups)
anova(bdinoc5)
## Analysis of Variance Table
## 
## Response: Distances
##           Df Sum Sq  Mean Sq F value    Pr(>F)    
## Groups     1 0.2356 0.235604  45.608 2.631e-08 ***
## Residuals 44 0.2273 0.005166                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.beta.disper.results.inoc5 <- permutest(bdinoc5, pairwise = TRUE, iter=9999)
pairwise.beta.disper.results.inoc5
## 
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 999
## 
## Response: Distances
##           Df Sum Sq  Mean Sq      F N.Perm Pr(>F)    
## Groups     1 0.2356 0.235604 45.608    999  0.001 ***
## Residuals 44 0.2273 0.005166                         
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Pairwise comparisons:
## (Observed p-value below diagonal, permuted p-value above diagonal)
##            T0    T1
## T0            0.001
## T1 2.6308e-08
bdinoc1
## 
##  Homogeneity of multivariate dispersions
## 
## Call: betadisper(d = disinoc1, group = groups)
## 
## No. of Positive Eigenvalues: 43
## No. of Negative Eigenvalues: 8
## 
## Average distance to median:
##     T0     T1 
## 0.3751 0.5540 
## 
## Eigenvalues for PCoA axes:
## (Showing 8 of 51 eigenvalues)
##  PCoA1  PCoA2  PCoA3  PCoA4  PCoA5  PCoA6  PCoA7  PCoA8 
## 4.2634 1.7811 1.1353 1.0183 0.8168 0.7478 0.6680 0.6191
bdinoc4
## 
##  Homogeneity of multivariate dispersions
## 
## Call: betadisper(d = disinoc4, group = groups)
## 
## No. of Positive Eigenvalues: 43
## No. of Negative Eigenvalues: 10
## 
## Average distance to median:
##     T0     T1 
## 0.3186 0.6003 
## 
## Eigenvalues for PCoA axes:
## (Showing 8 of 53 eigenvalues)
##  PCoA1  PCoA2  PCoA3  PCoA4  PCoA5  PCoA6  PCoA7  PCoA8 
## 4.5219 1.7736 1.0944 1.0326 0.8509 0.7851 0.6890 0.6410
bdinoc5
## 
##  Homogeneity of multivariate dispersions
## 
## Call: betadisper(d = disinoc5, group = groups)
## 
## No. of Positive Eigenvalues: 33
## No. of Negative Eigenvalues: 12
## 
## Average distance to median:
##     T0     T1 
## 0.3456 0.5134 
## 
## Eigenvalues for PCoA axes:
## (Showing 8 of 45 eigenvalues)
##  PCoA1  PCoA2  PCoA3  PCoA4  PCoA5  PCoA6  PCoA7  PCoA8 
## 3.3491 2.1401 1.2801 0.9504 0.8528 0.7280 0.5794 0.5086

beta dispersion and mantel test. Let’s do this with shoots and roots:

mantel test: (significant across inoculum, but not water treatment)

roots.dataframe<-as.data.frame(t(roots_post_stress$data_loaded))
dist.abund.root = vegdist(roots.dataframe, method = "bray")
inoc <- roots_post_stress$map_loaded$Inoculation
water <- roots_post_stress$map_loaded$Water
dist.inoc = dist(inoc, method = "euclidean")
dist.water = dist(water, method = "euclidean")
abund_inoc = mantel(dist.abund.root, dist.inoc, method = "spearman", permutations = 9999, na.rm = TRUE)
abund_inoc
## 
## Mantel statistic based on Spearman's rank correlation rho 
## 
## Call:
## mantel(xdis = dist.abund.root, ydis = dist.inoc, method = "spearman",      permutations = 9999, na.rm = TRUE) 
## 
## Mantel statistic r: 0.715 
##       Significance: 1e-04 
## 
## Upper quantiles of permutations (null model):
##    90%    95%  97.5%    99% 
## 0.0229 0.0316 0.0393 0.0487 
## Permutation: free
## Number of permutations: 9999
abund_water = mantel(dist.abund.root, dist.water, method = "spearman", permutations = 9999, na.rm = TRUE)
abund_water
## 
## Mantel statistic based on Spearman's rank correlation rho 
## 
## Call:
## mantel(xdis = dist.abund.root, ydis = dist.water, method = "spearman",      permutations = 9999, na.rm = TRUE) 
## 
## Mantel statistic r: 0.006851 
##       Significance: 0.2955 
## 
## Upper quantiles of permutations (null model):
##    90%    95%  97.5%    99% 
## 0.0193 0.0264 0.0331 0.0415 
## Permutation: free
## Number of permutations: 9999
shoots.dataframe<-as.data.frame(t(shoots_post_stress$data_loaded))
dist.abund.shoot = vegdist(shoots.dataframe, method = "bray")
inoc <- shoots_post_stress$map_loaded$Inoculation
water <- shoots_post_stress$map_loaded$Water
dist.inoc = dist(inoc, method = "euclidean")
dist.water = dist(water, method = "euclidean")
abund_inoc = mantel(dist.abund.shoot, dist.inoc, method = "spearman", permutations = 9999, na.rm = TRUE)
abund_inoc
## 
## Mantel statistic based on Spearman's rank correlation rho 
## 
## Call:
## mantel(xdis = dist.abund.shoot, ydis = dist.inoc, method = "spearman",      permutations = 9999, na.rm = TRUE) 
## 
## Mantel statistic r: 0.4485 
##       Significance: 1e-04 
## 
## Upper quantiles of permutations (null model):
##    90%    95%  97.5%    99% 
## 0.0305 0.0408 0.0507 0.0616 
## Permutation: free
## Number of permutations: 9999
abund_water = mantel(dist.abund.shoot, dist.water, method = "spearman", permutations = 9999, na.rm = TRUE)
abund_water
## 
## Mantel statistic based on Spearman's rank correlation rho 
## 
## Call:
## mantel(xdis = dist.abund.shoot, ydis = dist.water, method = "spearman",      permutations = 9999, na.rm = TRUE) 
## 
## Mantel statistic r: 0.1729 
##       Significance: 1e-04 
## 
## Upper quantiles of permutations (null model):
##    90%    95%  97.5%    99% 
## 0.0239 0.0321 0.0388 0.0467 
## Permutation: free
## Number of permutations: 9999

Let’s make the shannon’s diversity plots next:

#inputraw has the slurry data so let's take that first. Then we will need to transform it too. 
input <- load_taxa_table("data/ASV_table_postfiltering.txt", "data/map_loaded_strawberries.txt")
## 538 samples loaded
inputstep5 = filter_data(input, 'TimePoint', keep_vals = 'T1')
## 438 samples remaining
roott1 = filter_data(inputstep5, 'Type', keep_vals = 'Root')
## 219 samples remaining
roott1water1 = filter_data(roott1, 'Water', keep_vals = '1')
## 66 samples remaining
roott1inoc1water1 = filter_data(roott1water1, 'Inoculation', keep_vals = '1')
## 14 samples remaining
roott1inoc4water1 = filter_data(roott1water1, 'Inoculation', keep_vals = '4')
## 9 samples remaining
roott1inoc5water1 = filter_data(roott1water1, 'Inoculation', keep_vals = '5')
## 10 samples remaining
roott1inoc6water1 = filter_data(roott1water1, 'Inoculation', keep_vals = '6')
## 10 samples remaining
roott1water2 = filter_data(roott1, 'Water', keep_vals = '2')
## 74 samples remaining
roott1inoc1water2 = filter_data(roott1water2, 'Inoculation', keep_vals = '1')
## 13 samples remaining
roott1inoc4water2 = filter_data(roott1water2, 'Inoculation', keep_vals = '4')
## 12 samples remaining
roott1inoc5water2 = filter_data(roott1water2, 'Inoculation', keep_vals = '5')
## 12 samples remaining
roott1inoc6water2 = filter_data(roott1water2, 'Inoculation', keep_vals = '6')
## 11 samples remaining
roott1water3 = filter_data(roott1, 'Water', keep_vals = '3')
## 79 samples remaining
roott1inoc1water3 = filter_data(roott1water3, 'Inoculation', keep_vals = '1')
## 13 samples remaining
roott1inoc4water3 = filter_data(roott1water3, 'Inoculation', keep_vals = '4')
## 14 samples remaining
roott1inoc5water3 = filter_data(roott1water3, 'Inoculation', keep_vals = '5')
## 11 samples remaining
roott1inoc6water3 = filter_data(roott1water3, 'Inoculation', keep_vals = '6')
## 14 samples remaining
shoott1 = filter_data(inputstep5, 'Type', keep_vals = 'Shoot')
## 219 samples remaining
shoott1water1 = filter_data(shoott1, 'Water', keep_vals = '1')
## 67 samples remaining
shoott1inoc1water1 = filter_data(shoott1water1, 'Inoculation', keep_vals = '1')
## 13 samples remaining
shoott1inoc4water1 = filter_data(shoott1water1, 'Inoculation', keep_vals = '4')
## 9 samples remaining
shoott1inoc5water1 = filter_data(shoott1water1, 'Inoculation', keep_vals = '5')
## 11 samples remaining
shoott1inoc6water1 = filter_data(shoott1water1, 'Inoculation', keep_vals = '6')
## 10 samples remaining
shoott1water2 = filter_data(shoott1, 'Water', keep_vals = '2')
## 78 samples remaining
shoott1inoc1water2 = filter_data(shoott1water2, 'Inoculation', keep_vals = '1')
## 13 samples remaining
shoott1inoc4water2 = filter_data(shoott1water2, 'Inoculation', keep_vals = '4')
## 13 samples remaining
shoott1inoc5water2 = filter_data(shoott1water2, 'Inoculation', keep_vals = '5')
## 14 samples remaining
shoott1inoc6water2 = filter_data(shoott1water2, 'Inoculation', keep_vals = '6')
## 11 samples remaining
shoott1water3 = filter_data(shoott1, 'Water', keep_vals = '3')
## 74 samples remaining
shoott1inoc1water3 = filter_data(shoott1water3, 'Inoculation', keep_vals = '1')
## 12 samples remaining
shoott1inoc4water3 = filter_data(shoott1water3, 'Inoculation', keep_vals = '4')
## 13 samples remaining
shoott1inoc5water3 = filter_data(shoott1water3, 'Inoculation', keep_vals = '5')
## 10 samples remaining
shoott1inoc6water3 = filter_data(shoott1water3, 'Inoculation', keep_vals = '6')
## 12 samples remaining
t0 = filter_data(input, 'TimePoint', keep_vals = 'T0')
## 96 samples remaining
shoott0 = filter_data(t0, 'Type', keep_vals = 'Shoot')
## 96 samples remaining
shoott0inoc1 = filter_data(shoott0, 'Inoculation', keep_vals = '1')
## 14 samples remaining
shoott0inoc4 = filter_data(shoott0, 'Inoculation', keep_vals = '4')
## 19 samples remaining
shoott0inoc5 = filter_data(shoott0, 'Inoculation', keep_vals = '5')
## 11 samples remaining
shoott0inoc6 = filter_data(shoott0, 'Inoculation', keep_vals = '6')
## 18 samples remaining
#Now that we have all three ready, let's transform them to match our other data:
otuTAB<-roott1inoc1water1$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
otuTAB<-roott1inoc1water1$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
roott1inoc1water1$data_loaded<-t(hell)

otuTAB<-roott1inoc4water1$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
roott1inoc4water1$data_loaded<-t(hell)

otuTAB<-roott1inoc5water1$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
roott1inoc5water1$data_loaded<-t(hell)

otuTAB<-roott1inoc6water1$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
roott1inoc6water1$data_loaded<-t(hell)

otuTAB<-roott1inoc1water2$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
roott1inoc1water2$data_loaded<-t(hell)

otuTAB<-roott1inoc4water2$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
roott1inoc4water2$data_loaded<-t(hell)

otuTAB<-roott1inoc5water2$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
roott1inoc5water2$data_loaded<-t(hell)

otuTAB<-roott1inoc6water2$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
roott1inoc6water2$data_loaded<-t(hell)

otuTAB<-roott1inoc1water3$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
roott1inoc1water3$data_loaded<-t(hell)

otuTAB<-roott1inoc4water3$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
roott1inoc4water3$data_loaded<-t(hell)

otuTAB<-roott1inoc5water3$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
roott1inoc5water3$data_loaded<-t(hell)

otuTAB<-roott1inoc6water3$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
roott1inoc6water3$data_loaded<-t(hell)

otuTAB<-shoott1inoc1water1$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
shoott1inoc1water1$data_loaded<-t(hell)

otuTAB<-shoott1inoc4water1$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
shoott1inoc4water1$data_loaded<-t(hell)

otuTAB<-shoott1inoc5water1$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
shoott1inoc5water1$data_loaded<-t(hell)

otuTAB<-shoott1inoc6water1$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
shoott1inoc6water1$data_loaded<-t(hell)

otuTAB<-shoott1inoc1water2$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
shoott1inoc1water2$data_loaded<-t(hell)

otuTAB<-shoott1inoc4water2$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
shoott1inoc4water2$data_loaded<-t(hell)

otuTAB<-shoott1inoc5water2$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
shoott1inoc5water2$data_loaded<-t(hell)

otuTAB<-shoott1inoc6water2$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
shoott1inoc6water2$data_loaded<-t(hell)

otuTAB<-shoott1inoc1water3$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
shoott1inoc1water3$data_loaded<-t(hell)

otuTAB<-shoott1inoc4water3$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
shoott1inoc4water3$data_loaded<-t(hell)

otuTAB<-shoott1inoc5water3$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
shoott1inoc5water3$data_loaded<-t(hell)

otuTAB<-shoott1inoc6water3$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
shoott1inoc6water3$data_loaded<-t(hell)

otuTAB<-shoott0inoc1$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
shoott0inoc1$data_loaded<-t(hell)

otuTAB<-shoott0inoc4$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
shoott0inoc4$data_loaded<-t(hell)

otuTAB<-shoott0inoc5$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
shoott0inoc5$data_loaded<-t(hell)

otuTAB<-shoott0inoc6$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
#View(hell)
shoott0inoc6$data_loaded<-t(hell)

Now that we have the data, we can do shannon’s diversity:

#all shannon's diversity
library(vegan)
roott1inoc1water1<-diversity(t(roott1inoc1water1$data_loaded), index = "shannon")
roott1inoc4water1<-diversity(t(roott1inoc4water1$data_loaded), index = "shannon")
roott1inoc5water1<-diversity(t(roott1inoc5water1$data_loaded), index = "shannon")
roott1inoc6water1<-diversity(t(roott1inoc6water1$data_loaded), index = "shannon")
roott1inoc1water2<-diversity(t(roott1inoc1water2$data_loaded), index = "shannon")
roott1inoc4water2<-diversity(t(roott1inoc4water2$data_loaded), index = "shannon")
roott1inoc5water2<-diversity(t(roott1inoc5water2$data_loaded), index = "shannon")
roott1inoc6water2<-diversity(t(roott1inoc6water2$data_loaded), index = "shannon")
roott1inoc1water3<-diversity(t(roott1inoc1water3$data_loaded), index = "shannon")
roott1inoc4water3<-diversity(t(roott1inoc4water3$data_loaded), index = "shannon")
roott1inoc5water3<-diversity(t(roott1inoc5water3$data_loaded), index = "shannon")
roott1inoc6water3<-diversity(t(roott1inoc6water3$data_loaded), index = "shannon")

shoott1inoc1water1<-diversity(t(shoott1inoc1water1$data_loaded), index = "shannon")
shoott1inoc4water1<-diversity(t(shoott1inoc4water1$data_loaded), index = "shannon")
shoott1inoc5water1<-diversity(t(shoott1inoc5water1$data_loaded), index = "shannon")
shoott1inoc6water1<-diversity(t(shoott1inoc6water1$data_loaded), index = "shannon")
shoott1inoc1water2<-diversity(t(shoott1inoc1water2$data_loaded), index = "shannon")
shoott1inoc4water2<-diversity(t(shoott1inoc4water2$data_loaded), index = "shannon")
shoott1inoc5water2<-diversity(t(shoott1inoc5water2$data_loaded), index = "shannon")
shoott1inoc6water2<-diversity(t(shoott1inoc6water2$data_loaded), index = "shannon")
shoott1inoc1water3<-diversity(t(shoott1inoc1water3$data_loaded), index = "shannon")
shoott1inoc4water3<-diversity(t(shoott1inoc4water3$data_loaded), index = "shannon")
shoott1inoc5water3<-diversity(t(shoott1inoc5water3$data_loaded), index = "shannon")
shoott1inoc6water3<-diversity(t(shoott1inoc6water3$data_loaded), index = "shannon")

shoott0inoc1<-diversity(t(shoott0inoc1$data_loaded), index = "shannon")
shoott0inoc4<-diversity(t(shoott0inoc4$data_loaded), index = "shannon")
shoott0inoc5<-diversity(t(shoott0inoc5$data_loaded), index = "shannon")
shoott0inoc6<-diversity(t(shoott0inoc6$data_loaded), index = "shannon")

Next, lets make the dataframe for the ggplot - shannon’s (violin plot). We need to make sure we can panel it out too.

#roott1inoc1water1
roott1inoc1water1df<-as.data.frame(roott1inoc1water1)
colnames(roott1inoc1water1df)[1] ="shannon"
water<-rep("water1",times=nrow(roott1inoc1water1df))
inoculation<-rep("inoc1",times=nrow(roott1inoc1water1df))
type<-rep("root",times=nrow(roott1inoc1water1df))
roott1inoc1water1dffinal<-cbind(roott1inoc1water1df,water,inoculation,type)
#roott1inoc4water1
roott1inoc4water1df<-as.data.frame(roott1inoc4water1)
colnames(roott1inoc4water1df)[1] ="shannon"
water<-rep("water1",times=nrow(roott1inoc4water1df))
inoculation<-rep("inoc4",times=nrow(roott1inoc4water1df))
type<-rep("root",times=nrow(roott1inoc4water1df))
roott1inoc4water1dffinal<-cbind(roott1inoc4water1df,water,inoculation,type)
#roott1inoc5water1
roott1inoc5water1df<-as.data.frame(roott1inoc5water1)
colnames(roott1inoc5water1df)[1] ="shannon"
water<-rep("water1",times=nrow(roott1inoc5water1df))
inoculation<-rep("inoc5",times=nrow(roott1inoc5water1df))
type<-rep("root",times=nrow(roott1inoc5water1df))
roott1inoc5water1dffinal<-cbind(roott1inoc5water1df,water,inoculation,type)
#roott1inoc6water1
roott1inoc6water1df<-as.data.frame(roott1inoc6water1)
colnames(roott1inoc6water1df)[1] ="shannon"
water<-rep("water1",times=nrow(roott1inoc6water1df))
inoculation<-rep("inoc6",times=nrow(roott1inoc6water1df))
type<-rep("root",times=nrow(roott1inoc6water1df))
roott1inoc6water1dffinal<-cbind(roott1inoc6water1df,water,inoculation,type)
#roott1inoc1water2
roott1inoc1water2df<-as.data.frame(roott1inoc1water2)
colnames(roott1inoc1water2df)[1] ="shannon"
water<-rep("water2",times=nrow(roott1inoc1water2df))
inoculation<-rep("inoc1",times=nrow(roott1inoc1water2df))
type<-rep("root",times=nrow(roott1inoc1water2df))
roott1inoc1water2dffinal<-cbind(roott1inoc1water2df,water,inoculation,type)
#roott1inoc4water2
roott1inoc4water2df<-as.data.frame(roott1inoc4water2)
colnames(roott1inoc4water2df)[1] ="shannon"
water<-rep("water2",times=nrow(roott1inoc4water2df))
inoculation<-rep("inoc4",times=nrow(roott1inoc4water2df))
type<-rep("root",times=nrow(roott1inoc4water2df))
roott1inoc4water2dffinal<-cbind(roott1inoc4water2df,water,inoculation,type)
#roott1inoc5water2
roott1inoc5water2df<-as.data.frame(roott1inoc5water2)
colnames(roott1inoc5water2df)[1] ="shannon"
water<-rep("water2",times=nrow(roott1inoc5water2df))
inoculation<-rep("inoc5",times=nrow(roott1inoc5water2df))
type<-rep("root",times=nrow(roott1inoc5water2df))
roott1inoc5water2dffinal<-cbind(roott1inoc5water2df,water,inoculation,type)
#roott1inoc6water2
roott1inoc6water2df<-as.data.frame(roott1inoc6water2)
colnames(roott1inoc6water2df)[1] ="shannon"
water<-rep("water2",times=nrow(roott1inoc6water2df))
inoculation<-rep("inoc6",times=nrow(roott1inoc6water2df))
type<-rep("root",times=nrow(roott1inoc6water2df))
roott1inoc6water2dffinal<-cbind(roott1inoc6water2df,water,inoculation,type)
#roott1inoc1water3
roott1inoc1water3df<-as.data.frame(roott1inoc1water3)
colnames(roott1inoc1water3df)[1] ="shannon"
water<-rep("water3",times=nrow(roott1inoc1water3df))
inoculation<-rep("inoc1",times=nrow(roott1inoc1water3df))
type<-rep("root",times=nrow(roott1inoc1water3df))
roott1inoc1water3dffinal<-cbind(roott1inoc1water3df,water,inoculation,type)
#roott1inoc4water3
roott1inoc4water3df<-as.data.frame(roott1inoc4water3)
colnames(roott1inoc4water3df)[1] ="shannon"
water<-rep("water3",times=nrow(roott1inoc4water3df))
inoculation<-rep("inoc4",times=nrow(roott1inoc4water3df))
type<-rep("root",times=nrow(roott1inoc4water3df))
roott1inoc4water3dffinal<-cbind(roott1inoc4water3df,water,inoculation,type)
#roott1inoc5water3
roott1inoc5water3df<-as.data.frame(roott1inoc5water3)
colnames(roott1inoc5water3df)[1] ="shannon"
water<-rep("water3",times=nrow(roott1inoc5water3df))
inoculation<-rep("inoc5",times=nrow(roott1inoc5water3df))
type<-rep("root",times=nrow(roott1inoc5water3df))
roott1inoc5water3dffinal<-cbind(roott1inoc5water3df,water,inoculation,type)
#roott1inoc6water3
roott1inoc6water3df<-as.data.frame(roott1inoc6water3)
colnames(roott1inoc6water3df)[1] ="shannon"
water<-rep("water3",times=nrow(roott1inoc6water3df))
inoculation<-rep("inoc6",times=nrow(roott1inoc6water3df))
type<-rep("root",times=nrow(roott1inoc6water3df))
roott1inoc6water3dffinal<-cbind(roott1inoc6water3df,water,inoculation,type)
#shoott1inoc1water1
shoott1inoc1water1df<-as.data.frame(shoott1inoc1water1)
colnames(shoott1inoc1water1df)[1] ="shannon"
water<-rep("water1",times=nrow(shoott1inoc1water1df))
inoculation<-rep("inoc1",times=nrow(shoott1inoc1water1df))
type<-rep("shoot",times=nrow(shoott1inoc1water1df))
shoott1inoc1water1dffinal<-cbind(shoott1inoc1water1df,water,inoculation,type)
#shoott1inoc4water1
shoott1inoc4water1df<-as.data.frame(shoott1inoc4water1)
colnames(shoott1inoc4water1df)[1] ="shannon"
water<-rep("water1",times=nrow(shoott1inoc4water1df))
inoculation<-rep("inoc4",times=nrow(shoott1inoc4water1df))
type<-rep("shoot",times=nrow(shoott1inoc4water1df))
shoott1inoc4water1dffinal<-cbind(shoott1inoc4water1df,water,inoculation,type)
#shoott1inoc5water1
shoott1inoc5water1df<-as.data.frame(shoott1inoc5water1)
colnames(shoott1inoc5water1df)[1] ="shannon"
water<-rep("water1",times=nrow(shoott1inoc5water1df))
inoculation<-rep("inoc5",times=nrow(shoott1inoc5water1df))
type<-rep("shoot",times=nrow(shoott1inoc5water1df))
shoott1inoc5water1dffinal<-cbind(shoott1inoc5water1df,water,inoculation,type)
#shoott1inoc6water1
shoott1inoc6water1df<-as.data.frame(shoott1inoc6water1)
colnames(shoott1inoc6water1df)[1] ="shannon"
water<-rep("water1",times=nrow(shoott1inoc6water1df))
inoculation<-rep("inoc6",times=nrow(shoott1inoc6water1df))
type<-rep("shoot",times=nrow(shoott1inoc6water1df))
shoott1inoc6water1dffinal<-cbind(shoott1inoc6water1df,water,inoculation,type)
#shoott1inoc1water2
shoott1inoc1water2df<-as.data.frame(shoott1inoc1water2)
colnames(shoott1inoc1water2df)[1] ="shannon"
water<-rep("water2",times=nrow(shoott1inoc1water2df))
inoculation<-rep("inoc1",times=nrow(shoott1inoc1water2df))
type<-rep("shoot",times=nrow(shoott1inoc1water2df))
shoott1inoc1water2dffinal<-cbind(shoott1inoc1water2df,water,inoculation,type)
#shoott1inoc4water2
shoott1inoc4water2df<-as.data.frame(shoott1inoc4water2)
colnames(shoott1inoc4water2df)[1] ="shannon"
water<-rep("water2",times=nrow(shoott1inoc4water2df))
inoculation<-rep("inoc4",times=nrow(shoott1inoc4water2df))
type<-rep("shoot",times=nrow(shoott1inoc4water2df))
shoott1inoc4water2dffinal<-cbind(shoott1inoc4water2df,water,inoculation,type)
#shoott1inoc5water2
shoott1inoc5water2df<-as.data.frame(shoott1inoc5water2)
colnames(shoott1inoc5water2df)[1] ="shannon"
water<-rep("water2",times=nrow(shoott1inoc5water2df))
inoculation<-rep("inoc5",times=nrow(shoott1inoc5water2df))
type<-rep("shoot",times=nrow(shoott1inoc5water2df))
shoott1inoc5water2dffinal<-cbind(shoott1inoc5water2df,water,inoculation,type)
#shoott1inoc6water2
shoott1inoc6water2df<-as.data.frame(shoott1inoc6water2)
colnames(shoott1inoc6water2df)[1] ="shannon"
water<-rep("water2",times=nrow(shoott1inoc6water2df))
inoculation<-rep("inoc6",times=nrow(shoott1inoc6water2df))
type<-rep("shoot",times=nrow(shoott1inoc6water2df))
shoott1inoc6water2dffinal<-cbind(shoott1inoc6water2df,water,inoculation,type)
#shoott1inoc1water3
shoott1inoc1water3df<-as.data.frame(shoott1inoc1water3)
colnames(shoott1inoc1water3df)[1] ="shannon"
water<-rep("water3",times=nrow(shoott1inoc1water3df))
inoculation<-rep("inoc1",times=nrow(shoott1inoc1water3df))
type<-rep("shoot",times=nrow(shoott1inoc1water3df))
shoott1inoc1water3dffinal<-cbind(shoott1inoc1water3df,water,inoculation,type)
#shoott1inoc4water3
shoott1inoc4water3df<-as.data.frame(shoott1inoc4water3)
colnames(shoott1inoc4water3df)[1] ="shannon"
water<-rep("water3",times=nrow(shoott1inoc4water3df))
inoculation<-rep("inoc4",times=nrow(shoott1inoc4water3df))
type<-rep("shoot",times=nrow(shoott1inoc4water3df))
shoott1inoc4water3dffinal<-cbind(shoott1inoc4water3df,water,inoculation,type)
#shoott1inoc5water3
shoott1inoc5water3df<-as.data.frame(shoott1inoc5water3)
colnames(shoott1inoc5water3df)[1] ="shannon"
water<-rep("water3",times=nrow(shoott1inoc5water3df))
inoculation<-rep("inoc5",times=nrow(shoott1inoc5water3df))
type<-rep("shoot",times=nrow(shoott1inoc5water3df))
shoott1inoc5water3dffinal<-cbind(shoott1inoc5water3df,water,inoculation,type)
#shoott1inoc6water3
shoott1inoc6water3df<-as.data.frame(shoott1inoc6water3)
colnames(shoott1inoc6water3df)[1] ="shannon"
water<-rep("water3",times=nrow(shoott1inoc6water3df))
inoculation<-rep("inoc6",times=nrow(shoott1inoc6water3df))
type<-rep("shoot",times=nrow(shoott1inoc6water3df))
shoott1inoc6water3dffinal<-cbind(shoott1inoc6water3df,water,inoculation,type)

#shoottinoc1
shoott0inoc1df<-as.data.frame(shoott0inoc1)
colnames(shoott0inoc1df)[1] ="shannon"
inoculation<-rep("inoc1",times=nrow(shoott0inoc1df))
shoott0inoc1dffinal<-cbind(shoott0inoc1df,inoculation)

#shoottinoc4
shoott0inoc4df<-as.data.frame(shoott0inoc4)
colnames(shoott0inoc4df)[1] ="shannon"
inoculation<-rep("inoc4",times=nrow(shoott0inoc4df))
shoott0inoc4dffinal<-cbind(shoott0inoc4df,inoculation)

#shoottinoc5
shoott0inoc5df<-as.data.frame(shoott0inoc5)
colnames(shoott0inoc5df)[1] ="shannon"
inoculation<-rep("inoc5",times=nrow(shoott0inoc5df))
shoott0inoc5dffinal<-cbind(shoott0inoc5df,inoculation)

#shoottinoc6
shoott0inoc6df<-as.data.frame(shoott0inoc6)
colnames(shoott0inoc6df)[1] ="shannon"
inoculation<-rep("inoc6",times=nrow(shoott0inoc6df))
shoott0inoc6dffinal<-cbind(shoott0inoc6df,inoculation)

#now rbind them together
shanfinalbindt0<-do.call("rbind",list(shoott0inoc1dffinal,shoott0inoc4dffinal,shoott0inoc5dffinal,shoott0inoc6dffinal))
shanfinalbindt1<-do.call("rbind",list(roott1inoc1water1dffinal,roott1inoc4water1dffinal,roott1inoc5water1dffinal,roott1inoc6water1dffinal,roott1inoc1water2dffinal,roott1inoc4water2dffinal,roott1inoc5water2dffinal,roott1inoc6water2dffinal,roott1inoc1water3dffinal,roott1inoc4water3dffinal,roott1inoc5water3dffinal,roott1inoc6water3dffinal,shoott1inoc1water1dffinal,shoott1inoc4water1dffinal,shoott1inoc5water1dffinal,shoott1inoc6water1dffinal,shoott1inoc1water2dffinal,shoott1inoc4water2dffinal,shoott1inoc5water2dffinal,shoott1inoc6water2dffinal,shoott1inoc1water3dffinal,shoott1inoc4water3dffinal,shoott1inoc5water3dffinal,shoott1inoc6water3dffinal))

Shoots T0 Shannon’s Diversity

shannonviolint0<-ggplot(shanfinalbindt0,aes(x=inoculation,y=shannon,color=factor(inoculation))) + 
  ggtitle("T0 Shannon's Diversity Shoots Only")+
  geom_violin()+
  geom_point()+

  theme(
    axis.text = element_text(color='black',size=10),
    axis.title = element_text(color='black',size=12),
    axis.ticks = element_line(color='black'),
    legend.title = element_text(size=8),
    panel.background = element_rect(fill=NA,color='black'),
    panel.grid = element_blank(),
    plot.title=element_text(size=20,face="bold",vjust=2))

shannonviolint0

ggsave("figures/shannonviolint0.pdf", height=6, width=12)

#ggsave(filename = "shannonviolint0.pdf",
#      plot = shannonviolint0,
#      bg = "transparent",
#      width = 12, height = 6, units = "in",
#      dpi = 600)

T1 Shannon’s Diversity

shannonviolint1<-ggplot(shanfinalbindt1,aes(x=inoculation,y=shannon,color=factor(type))) + 
  ggtitle("T1 Shannon's Diversity Shoots and Roots")+
  geom_violin(position=position_dodge(width = 0.5))+
  geom_point(position=position_dodge(width = 0.5))+
  facet_grid(.~water,scales ="free",space="free")+
  theme(
    axis.text = element_text(color='black',size=10),
    axis.title = element_text(color='black',size=12),
    axis.ticks = element_line(color='black'),
    legend.title = element_text(size=8),
    panel.background = element_rect(fill=NA,color='black'),
    panel.grid = element_blank(),
    plot.title=element_text(size=20,face="bold",vjust=2))

shannonviolint1

ggsave("figures/shannonviolint1.pdf", height=6, width=12)

#ggsave(filename = "shannonviolint1.pdf",
#      plot = shannonviolint1,
#      bg = "transparent",
#      width = 12, height = 6, units = "in",
#      dpi = 600)

#Stats of T0 to T1

time<-rep("t0",times=nrow(shanfinalbindt0))
shanfinalbindt0_time<-cbind(shanfinalbindt0,time)
shanfinalbindt1_time<-subset(shanfinalbindt1,type!="root")
time<-rep("t1",times=nrow(shanfinalbindt1_time))
shanfinalbindt1_time_final<-cbind(shanfinalbindt1_time,time)
shanfinalbindt1_time_final<-shanfinalbindt1_time_final[-c(2,4)]
statsdf<-rbind(shanfinalbindt0_time,shanfinalbindt1_time_final)
timemodel<-lm(shannon~time,statsdf)
library(car)
anova(timemodel)
## Analysis of Variance Table
## 
## Response: shannon
##            Df Sum Sq Mean Sq F value    Pr(>F)    
## time        1 13.906 13.9062   105.5 < 2.2e-16 ***
## Residuals 201 26.494  0.1318                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Stats of T1 graphs

#View(shanfinalbindt1)
shanfinalbindt1water1<-subset(shanfinalbindt1,water!="water2"&water!="water3")
shanfinalbindt1water2<-subset(shanfinalbindt1,water!="water1"&water!="water3")
shanfinalbindt1water3<-subset(shanfinalbindt1,water!="water2"&water!="water1")

Water 1 stats

water1model<-lm(shannon~type*inoculation,shanfinalbindt1water1)
Anova(water1model,type=3)
## Anova Table (Type III tests)
## 
## Response: shannon
##                   Sum Sq Df   F value    Pr(>F)    
## (Intercept)      144.530  1 1602.1474 < 2.2e-16 ***
## type               7.672  1   85.0505 4.000e-14 ***
## inoculation        7.080  3   26.1596 8.232e-12 ***
## type:inoculation   2.672  3    9.8745 1.358e-05 ***
## Residuals          7.036 78                        
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(water1model,pairwise~inoculation|type)
## $emmeans
## type = root:
##  inoculation emmean     SE df lower.CL upper.CL
##  inoc1         3.21 0.0803 78     3.05     3.37
##  inoc4         3.62 0.1001 78     3.42     3.82
##  inoc5         2.91 0.0950 78     2.72     3.09
##  inoc6         2.45 0.0950 78     2.27     2.64
## 
## type = shoot:
##  inoculation emmean     SE df lower.CL upper.CL
##  inoc1         2.15 0.0833 78     1.98     2.31
##  inoc4         2.30 0.1001 78     2.10     2.50
##  inoc5         2.14 0.0906 78     1.96     2.32
##  inoc6         2.12 0.0950 78     1.93     2.31
## 
## Confidence level used: 0.95 
## 
## $contrasts
## type = root:
##  contrast      estimate    SE df t.ratio p.value
##  inoc1 - inoc4 -0.41027 0.128 78  -3.197  0.0106
##  inoc1 - inoc5  0.30739 0.124 78   2.472  0.0724
##  inoc1 - inoc6  0.75810 0.124 78   6.096  <.0001
##  inoc4 - inoc5  0.71766 0.138 78   5.200  <.0001
##  inoc4 - inoc6  1.16837 0.138 78   8.466  <.0001
##  inoc5 - inoc6  0.45071 0.134 78   3.355  0.0066
## 
## type = shoot:
##  contrast      estimate    SE df t.ratio p.value
##  inoc1 - inoc4 -0.15394 0.130 78  -1.182  0.6400
##  inoc1 - inoc5  0.00857 0.123 78   0.070  0.9999
##  inoc1 - inoc6  0.02579 0.126 78   0.204  0.9970
##  inoc4 - inoc5  0.16251 0.135 78   1.204  0.6263
##  inoc4 - inoc6  0.17973 0.138 78   1.302  0.5642
##  inoc5 - inoc6  0.01722 0.131 78   0.131  0.9992
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
emmeans(water1model,pairwise~type|inoculation)
## $emmeans
## inoculation = inoc1:
##  type  emmean     SE df lower.CL upper.CL
##  root    3.21 0.0803 78     3.05     3.37
##  shoot   2.15 0.0833 78     1.98     2.31
## 
## inoculation = inoc4:
##  type  emmean     SE df lower.CL upper.CL
##  root    3.62 0.1001 78     3.42     3.82
##  shoot   2.30 0.1001 78     2.10     2.50
## 
## inoculation = inoc5:
##  type  emmean     SE df lower.CL upper.CL
##  root    2.91 0.0950 78     2.72     3.09
##  shoot   2.14 0.0906 78     1.96     2.32
## 
## inoculation = inoc6:
##  type  emmean     SE df lower.CL upper.CL
##  root    2.45 0.0950 78     2.27     2.64
##  shoot   2.12 0.0950 78     1.93     2.31
## 
## Confidence level used: 0.95 
## 
## $contrasts
## inoculation = inoc1:
##  contrast     estimate    SE df t.ratio p.value
##  root - shoot    1.067 0.116 78   9.222  <.0001
## 
## inoculation = inoc4:
##  contrast     estimate    SE df t.ratio p.value
##  root - shoot    1.323 0.142 78   9.346  <.0001
## 
## inoculation = inoc5:
##  contrast     estimate    SE df t.ratio p.value
##  root - shoot    0.768 0.131 78   5.853  <.0001
## 
## inoculation = inoc6:
##  contrast     estimate    SE df t.ratio p.value
##  root - shoot    0.335 0.134 78   2.491  0.0149

Water 2 stats

water2model<-lm(shannon~type*inoculation,shanfinalbindt1water2)
Anova(water2model,type=3)
## Anova Table (Type III tests)
## 
## Response: shannon
##                   Sum Sq Df  F value    Pr(>F)    
## (Intercept)      146.009  1 1895.098 < 2.2e-16 ***
## type               8.154  1  105.827 < 2.2e-16 ***
## inoculation        9.219  3   39.884 < 2.2e-16 ***
## type:inoculation   2.464  3   10.659 4.517e-06 ***
## Residuals          7.011 91                       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(water2model,pairwise~inoculation|type)
## $emmeans
## type = root:
##  inoculation emmean     SE df lower.CL upper.CL
##  inoc1         3.35 0.0770 91     3.20     3.50
##  inoc4         3.53 0.0801 91     3.37     3.69
##  inoc5         3.01 0.0801 91     2.85     3.17
##  inoc6         2.36 0.0837 91     2.19     2.52
## 
## type = shoot:
##  inoculation emmean     SE df lower.CL upper.CL
##  inoc1         2.23 0.0770 91     2.08     2.38
##  inoc4         2.38 0.0770 91     2.22     2.53
##  inoc5         2.22 0.0742 91     2.08     2.37
##  inoc6         2.01 0.0837 91     1.84     2.18
## 
## Confidence level used: 0.95 
## 
## $contrasts
## type = root:
##  contrast      estimate    SE df t.ratio p.value
##  inoc1 - inoc4 -0.18225 0.111 91  -1.640  0.3615
##  inoc1 - inoc5  0.33878 0.111 91   3.049  0.0156
##  inoc1 - inoc6  0.99364 0.114 91   8.738  <.0001
##  inoc4 - inoc5  0.52104 0.113 91   4.598  0.0001
##  inoc4 - inoc6  1.17589 0.116 91  10.149  <.0001
##  inoc5 - inoc6  0.65486 0.116 91   5.652  <.0001
## 
## type = shoot:
##  contrast      estimate    SE df t.ratio p.value
##  inoc1 - inoc4 -0.14449 0.109 91  -1.327  0.5482
##  inoc1 - inoc5  0.00871 0.107 91   0.081  0.9998
##  inoc1 - inoc6  0.22154 0.114 91   1.948  0.2155
##  inoc4 - inoc5  0.15320 0.107 91   1.433  0.4823
##  inoc4 - inoc6  0.36603 0.114 91   3.219  0.0095
##  inoc5 - inoc6  0.21283 0.112 91   1.903  0.2340
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
emmeans(water2model,pairwise~type|inoculation)
## $emmeans
## inoculation = inoc1:
##  type  emmean     SE df lower.CL upper.CL
##  root    3.35 0.0770 91     3.20     3.50
##  shoot   2.23 0.0770 91     2.08     2.38
## 
## inoculation = inoc4:
##  type  emmean     SE df lower.CL upper.CL
##  root    3.53 0.0801 91     3.37     3.69
##  shoot   2.38 0.0770 91     2.22     2.53
## 
## inoculation = inoc5:
##  type  emmean     SE df lower.CL upper.CL
##  root    3.01 0.0801 91     2.85     3.17
##  shoot   2.22 0.0742 91     2.08     2.37
## 
## inoculation = inoc6:
##  type  emmean     SE df lower.CL upper.CL
##  root    2.36 0.0837 91     2.19     2.52
##  shoot   2.01 0.0837 91     1.84     2.18
## 
## Confidence level used: 0.95 
## 
## $contrasts
## inoculation = inoc1:
##  contrast     estimate    SE df t.ratio p.value
##  root - shoot    1.120 0.109 91  10.287  <.0001
## 
## inoculation = inoc4:
##  contrast     estimate    SE df t.ratio p.value
##  root - shoot    1.158 0.111 91  10.419  <.0001
## 
## inoculation = inoc5:
##  contrast     estimate    SE df t.ratio p.value
##  root - shoot    0.790 0.109 91   7.234  <.0001
## 
## inoculation = inoc6:
##  contrast     estimate    SE df t.ratio p.value
##  root - shoot    0.348 0.118 91   2.939  0.0042

Water 3 stats

water3model<-lm(shannon~type*inoculation,shanfinalbindt1water3)
Anova(water3model,type=3)
## Anova Table (Type III tests)
## 
## Response: shannon
##                   Sum Sq Df  F value    Pr(>F)    
## (Intercept)      135.404  1 2333.932 < 2.2e-16 ***
## type               4.750  1   81.868 2.505e-14 ***
## inoculation        6.328  3   36.358 1.547e-15 ***
## type:inoculation   2.251  3   12.932 4.132e-07 ***
## Residuals          5.279 91                       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(water3model,pairwise~inoculation|type)
## $emmeans
## type = root:
##  inoculation emmean     SE df lower.CL upper.CL
##  inoc1         3.23 0.0668 91     3.09     3.36
##  inoc4         3.43 0.0644 91     3.31     3.56
##  inoc5         2.92 0.0726 91     2.77     3.06
##  inoc6         2.54 0.0644 91     2.41     2.67
## 
## type = shoot:
##  inoculation emmean     SE df lower.CL upper.CL
##  inoc1         2.35 0.0695 91     2.22     2.49
##  inoc4         2.60 0.0668 91     2.47     2.74
##  inoc5         2.52 0.0762 91     2.37     2.68
##  inoc6         2.37 0.0695 91     2.23     2.51
## 
## Confidence level used: 0.95 
## 
## $contrasts
## type = root:
##  contrast      estimate     SE df t.ratio p.value
##  inoc1 - inoc4  -0.2068 0.0928 91  -2.229  0.1232
##  inoc1 - inoc5   0.3095 0.0987 91   3.137  0.0121
##  inoc1 - inoc6   0.6899 0.0928 91   7.437  <.0001
##  inoc4 - inoc5   0.5163 0.0970 91   5.320  <.0001
##  inoc4 - inoc6   0.8967 0.0910 91   9.850  <.0001
##  inoc5 - inoc6   0.3804 0.0970 91   3.920  0.0010
## 
## type = shoot:
##  contrast      estimate     SE df t.ratio p.value
##  inoc1 - inoc4  -0.2491 0.0964 91  -2.583  0.0544
##  inoc1 - inoc5  -0.1696 0.1031 91  -1.644  0.3593
##  inoc1 - inoc6  -0.0177 0.0983 91  -0.180  0.9979
##  inoc4 - inoc5   0.0795 0.1013 91   0.785  0.8613
##  inoc4 - inoc6   0.2314 0.0964 91   2.400  0.0843
##  inoc5 - inoc6   0.1519 0.1031 91   1.473  0.4580
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
emmeans(water3model,pairwise~type|inoculation)
## $emmeans
## inoculation = inoc1:
##  type  emmean     SE df lower.CL upper.CL
##  root    3.23 0.0668 91     3.09     3.36
##  shoot   2.35 0.0695 91     2.22     2.49
## 
## inoculation = inoc4:
##  type  emmean     SE df lower.CL upper.CL
##  root    3.43 0.0644 91     3.31     3.56
##  shoot   2.60 0.0668 91     2.47     2.74
## 
## inoculation = inoc5:
##  type  emmean     SE df lower.CL upper.CL
##  root    2.92 0.0726 91     2.77     3.06
##  shoot   2.52 0.0762 91     2.37     2.68
## 
## inoculation = inoc6:
##  type  emmean     SE df lower.CL upper.CL
##  root    2.54 0.0644 91     2.41     2.67
##  shoot   2.37 0.0695 91     2.23     2.51
## 
## Confidence level used: 0.95 
## 
## $contrasts
## inoculation = inoc1:
##  contrast     estimate     SE df t.ratio p.value
##  root - shoot    0.872 0.0964 91   9.048  <.0001
## 
## inoculation = inoc4:
##  contrast     estimate     SE df t.ratio p.value
##  root - shoot    0.830 0.0928 91   8.948  <.0001
## 
## inoculation = inoc5:
##  contrast     estimate     SE df t.ratio p.value
##  root - shoot    0.393 0.1052 91   3.738  0.0003
## 
## inoculation = inoc6:
##  contrast     estimate     SE df t.ratio p.value
##  root - shoot    0.165 0.0948 91   1.740  0.0853

Let’s make some stacked bar plots too:

#let's refilter again to just root t1, shoot t1, and shoot t0
#Pair down the other data. We will have to hellinger transform this data too
input <- load_taxa_table("data/ASV_table_postfiltering.txt", "data/map_loaded_strawberries.txt")
## 538 samples loaded
inputstep5 = filter_data(input, 'TimePoint', keep_vals = 'T1')
## 438 samples remaining
roott1 = filter_data(inputstep5, 'Type', keep_vals = 'Root')
## 219 samples remaining
roott1 = filter_data(roott1, 'Inoculation', filter_vals = '2')
## 180 samples remaining
roott1 = filter_data(roott1, 'Inoculation', filter_vals = '3')
## 143 samples remaining
shoott1 = filter_data(inputstep5, 'Type', keep_vals = 'Shoot')
## 219 samples remaining
shoott1 = filter_data(shoott1, 'Inoculation', filter_vals = '2')
## 178 samples remaining
shoott1 = filter_data(shoott1, 'Inoculation', filter_vals = '3')
## 141 samples remaining
time0 = filter_data(input,'TimePoint',keep_vals = 'T0')
## 96 samples remaining
shoott0 = filter_data(time0, 'Type', keep_vals = 'Shoot')
## 96 samples remaining
shoott0 = filter_data(shoott0, 'Inoculation', filter_vals = '2')
## 76 samples remaining
shoott0 = filter_data(shoott0, 'Inoculation', filter_vals = '3')
## 62 samples remaining
#transformation
library(labdsv)
otuTAB<-shoott1$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
shoott1$data_loaded<-t(hell)

otuTAB<-roott1$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
roott1$data_loaded<-t(hell)

otuTAB<-shoott0$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
shoott0$data_loaded<-t(hell)

We will need to make a large dataframe here. View after melting to see how many columns to make. This will be family level

library(reshape2)
## 
## Attaching package: 'reshape2'
## The following object is masked from 'package:tidyr':
## 
##     smiths
#level=5 is family. 
shoott1_tax_sum_family = summarize_taxonomy(shoott1, level = 5, report_higher_tax = FALSE)
shoott1_tax_sum_family$family <-row.names(shoott1_tax_sum_family)
shoott1_melt<- melt(shoott1_tax_sum_family, id.var="family")
nrow(shoott1_melt)
treatment<-rep("shoot_t1",times=nrow(shoott1_melt))
shoott1_melt<-cbind(shoott1_melt,treatment)

roott1_tax_sum_family = summarize_taxonomy(roott1, level = 5, report_higher_tax = FALSE)
roott1_tax_sum_family$family <-row.names(roott1_tax_sum_family)
roott1_melt<- melt(roott1_tax_sum_family, id.var="family")
nrow(roott1_melt)
treatment<-rep("root_t1",times=nrow(roott1_melt))
roott1_melt<-cbind(roott1_melt,treatment)

shoott0_tax_sum_family = summarize_taxonomy(shoott0, level = 5, report_higher_tax = FALSE)
shoott0_tax_sum_family$family <-row.names(shoott0_tax_sum_family)
shoott0_melt<- melt(shoott0_tax_sum_family, id.var="family")
nrow(shoott0_melt)
treatment<-rep("shoot_t0",times=nrow(shoott0_melt))
shoott0_melt<-cbind(shoott0_melt,treatment)

familyfinalbind<-do.call("rbind",list(shoott1_melt,roott1_melt,shoott0_melt))

family graph

library(ggthemes)
library(ggplot2)
familygraph<-ggplot(familyfinalbind, aes(x = treatment, y = value, fill = family)) + 
  geom_bar(stat="identity",position = "fill") + 
  scale_y_continuous(labels = scales::percent) +
  scale_fill_manual(values = colorRampPalette(solarized_pal()(8))(92)) + 
  ggtitle("Family Graphs")+

  theme(
    axis.text = element_text(color='black',size=10),
    axis.title.y= element_blank(),
    axis.title.x= element_blank(),
    axis.title = element_text(color='black',size=12),
    axis.ticks = element_line(color='black'),
    legend.title = element_text(size=18),
    panel.background = element_rect(fill=NA,color='black'),
    panel.grid = element_blank(),
    legend.key.size = unit(0.1, 'mm'),
    plot.title=element_text(size=20,face="bold",vjust=2))

familygraph

ggsave("figures/familygraph.pdf", height=8, width=17)

#ggsave(filename = "familygraph.pdf",
#       plot = familygraph,
#       bg = "transparent",
#       width = 17, height = 8, units = "in",
#       dpi = 600)

Let’s try class

library(reshape2)
#level=4 is class. 
shoott1_tax_sum_class = summarize_taxonomy(shoott1, level = 4, report_higher_tax = FALSE)
shoott1_tax_sum_class$class <-row.names(shoott1_tax_sum_class)
shoott1_melt<- melt(shoott1_tax_sum_class, id.var="class")
nrow(shoott1_melt)
treatment<-rep("shoot_t1",times=nrow(shoott1_melt))
shoott1_melt<-cbind(shoott1_melt,treatment)

roott1_tax_sum_class = summarize_taxonomy(roott1, level = 4, report_higher_tax = FALSE)
roott1_tax_sum_class$class <-row.names(roott1_tax_sum_class)
roott1_melt<- melt(roott1_tax_sum_class, id.var="class")
nrow(roott1_melt)
treatment<-rep("root_t1",times=nrow(roott1_melt))
roott1_melt<-cbind(roott1_melt,treatment)

shoott0_tax_sum_class = summarize_taxonomy(shoott0, level = 4, report_higher_tax = FALSE)
shoott0_tax_sum_class$class <-row.names(shoott0_tax_sum_class)
shoott0_melt<- melt(shoott0_tax_sum_class, id.var="class")
nrow(shoott0_melt)
treatment<-rep("shoot_t0",times=nrow(shoott0_melt))
shoott0_melt<-cbind(shoott0_melt,treatment)

classfinalbind<-do.call("rbind",list(shoott1_melt,roott1_melt,shoott0_melt))

class graph

library(ggthemes)
library(ggplot2)
classgraph<-ggplot(classfinalbind, aes(x = treatment, y = value, fill = class)) + 
  geom_bar(stat="identity",position = "fill") + 
  scale_y_continuous(labels = scales::percent) +
  scale_fill_manual(values = colorRampPalette(solarized_pal()(8))(51)) + 
  ggtitle("class Graphs")+

  theme(
    axis.text = element_text(color='black',size=10),
    axis.title.y= element_blank(),
    axis.title.x= element_blank(),
    axis.title = element_text(color='black',size=12),
    axis.ticks = element_line(color='black'),
    legend.title = element_text(size=18),
    panel.background = element_rect(fill=NA,color='black'),
    panel.grid = element_blank(),
    legend.key.size = unit(0.5, 'mm'),
    plot.title=element_text(size=20,face="bold",vjust=2))

classgraph

ggsave("figures/classgraph.pdf", height=6, width=10)

#ggsave(filename = "classgraph.pdf",
#       plot = classgraph,
#       bg = "transparent",
#      width = 10, height = 6, units = "in",
#       dpi = 600)

Now we can make t1 shoots by inoculation and water treatment

#let's refilter again just in case but include the control too
#Pair down the other data. We will have to hellinger transform this data too
library(mctoolsr)
library(ggplot2)
library(labdsv)
inputstep5 = filter_data(input, 'TimePoint', keep_vals = 'T1')
## 438 samples remaining
shoots = filter_data(inputstep5, 'Type', keep_vals = 'Shoot')
## 219 samples remaining
water1 = filter_data(shoots, 'Water', keep_vals = '1')
## 67 samples remaining
water1inoc1 = filter_data(water1, 'Inoculation', keep_vals = '1')
## 13 samples remaining
water1inoc4 = filter_data(water1, 'Inoculation', keep_vals = '4')
## 9 samples remaining
water1inoc5 = filter_data(water1, 'Inoculation', keep_vals = '5')
## 11 samples remaining
water1inoc6 = filter_data(water1, 'Inoculation', keep_vals = '6')
## 10 samples remaining
water2 = filter_data(inputstep5, 'Water', keep_vals = '2')
## 152 samples remaining
water2inoc1 = filter_data(water2, 'Inoculation', keep_vals = '1')
## 26 samples remaining
water2inoc4 = filter_data(water2, 'Inoculation', keep_vals = '4')
## 25 samples remaining
water2inoc5 = filter_data(water2, 'Inoculation', keep_vals = '5')
## 26 samples remaining
water2inoc6 = filter_data(water2, 'Inoculation', keep_vals = '6')
## 22 samples remaining
water3 = filter_data(inputstep5, 'Water', keep_vals = '3')
## 153 samples remaining
water3inoc1 = filter_data(water3, 'Inoculation', keep_vals = '1')
## 25 samples remaining
water3inoc4 = filter_data(water3, 'Inoculation', keep_vals = '4')
## 27 samples remaining
water3inoc5 = filter_data(water3, 'Inoculation', keep_vals = '5')
## 21 samples remaining
water3inoc6 = filter_data(water3, 'Inoculation', keep_vals = '6')
## 26 samples remaining
#transformation
otuTAB<-water1inoc1$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water1inoc1$data_loaded<-t(hell)
otuTAB<-water1inoc4$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water1inoc4$data_loaded<-t(hell)
otuTAB<-water1inoc5$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water1inoc5$data_loaded<-t(hell)
otuTAB<-water1inoc6$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water1inoc6$data_loaded<-t(hell)

otuTAB<-water2inoc1$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water2inoc1$data_loaded<-t(hell)
otuTAB<-water2inoc4$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water2inoc4$data_loaded<-t(hell)
otuTAB<-water2inoc5$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water2inoc5$data_loaded<-t(hell)
otuTAB<-water2inoc6$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water2inoc6$data_loaded<-t(hell)

otuTAB<-water3inoc1$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water3inoc1$data_loaded<-t(hell)
otuTAB<-water3inoc4$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water3inoc4$data_loaded<-t(hell)
otuTAB<-water3inoc5$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water3inoc5$data_loaded<-t(hell)
otuTAB<-water3inoc6$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water3inoc6$data_loaded<-t(hell)

We will need to make a large dataframe here. View after melting to see how many columns to make. This will be family for shoots

library(reshape2)
water1inoc1_tax_sum_family = summarize_taxonomy(water1inoc1, level = 5, report_higher_tax = FALSE)
water1inoc1_tax_sum_family$family <-row.names(water1inoc1_tax_sum_family)
water1inoc1_melt<- melt(water1inoc1_tax_sum_family, id.var="family")
nrow(water1inoc1_melt)
inoculation<-rep("inoc1",times=nrow(water1inoc1_melt))
water<-rep("water1",times=nrow(water1inoc1_melt))
water1inoc1_melt<-cbind(water1inoc1_melt,inoculation,water)

water1inoc4_tax_sum_family = summarize_taxonomy(water1inoc4, level = 5, report_higher_tax = FALSE)
water1inoc4_tax_sum_family$family <-row.names(water1inoc4_tax_sum_family)
water1inoc4_melt<- melt(water1inoc4_tax_sum_family, id.var="family")
nrow(water1inoc4_melt)
inoculation<-rep("inoc4",times=nrow(water1inoc4_melt))
water<-rep("water1",times=nrow(water1inoc4_melt))
water1inoc4_melt<-cbind(water1inoc4_melt,inoculation,water)

water1inoc5_tax_sum_family = summarize_taxonomy(water1inoc5, level = 5, report_higher_tax = FALSE)
water1inoc5_tax_sum_family$family <-row.names(water1inoc5_tax_sum_family)
water1inoc5_melt<- melt(water1inoc5_tax_sum_family, id.var="family")
nrow(water1inoc5_melt)
inoculation<-rep("inoc5",times=nrow(water1inoc5_melt))
water<-rep("water1",times=nrow(water1inoc5_melt))
water1inoc5_melt<-cbind(water1inoc5_melt,inoculation,water)

water1inoc6_tax_sum_family = summarize_taxonomy(water1inoc6, level = 5, report_higher_tax = FALSE)
water1inoc6_tax_sum_family$family <-row.names(water1inoc6_tax_sum_family)
water1inoc6_melt<- melt(water1inoc6_tax_sum_family, id.var="family")
nrow(water1inoc6_melt)
inoculation<-rep("inoc6",times=nrow(water1inoc6_melt))
water<-rep("water1",times=nrow(water1inoc6_melt))
water1inoc6_melt<-cbind(water1inoc6_melt,inoculation,water)

water2inoc1_tax_sum_family = summarize_taxonomy(water2inoc1, level = 5, report_higher_tax = FALSE)
water2inoc1_tax_sum_family$family <-row.names(water2inoc1_tax_sum_family)
water2inoc1_melt<- melt(water2inoc1_tax_sum_family, id.var="family")
nrow(water2inoc1_melt)
inoculation<-rep("inoc1",times=nrow(water2inoc1_melt))
water<-rep("water2",times=nrow(water2inoc1_melt))
water2inoc1_melt<-cbind(water2inoc1_melt,inoculation,water)

water2inoc4_tax_sum_family = summarize_taxonomy(water2inoc4, level = 5, report_higher_tax = FALSE)
water2inoc4_tax_sum_family$family <-row.names(water2inoc4_tax_sum_family)
water2inoc4_melt<- melt(water2inoc4_tax_sum_family, id.var="family")
nrow(water2inoc4_melt)
inoculation<-rep("inoc4",times=nrow(water2inoc4_melt))
water<-rep("water2",times=nrow(water2inoc4_melt))
water2inoc4_melt<-cbind(water2inoc4_melt,inoculation,water)

water2inoc5_tax_sum_family = summarize_taxonomy(water2inoc5, level = 5, report_higher_tax = FALSE)
water2inoc5_tax_sum_family$family <-row.names(water2inoc5_tax_sum_family)
water2inoc5_melt<- melt(water2inoc5_tax_sum_family, id.var="family")
nrow(water2inoc5_melt)
inoculation<-rep("inoc5",times=nrow(water2inoc5_melt))
water<-rep("water2",times=nrow(water2inoc5_melt))
water2inoc5_melt<-cbind(water2inoc5_melt,inoculation,water)

water2inoc6_tax_sum_family = summarize_taxonomy(water2inoc6, level = 5, report_higher_tax = FALSE)
water2inoc6_tax_sum_family$family <-row.names(water2inoc6_tax_sum_family)
water2inoc6_melt<- melt(water2inoc6_tax_sum_family, id.var="family")
nrow(water2inoc6_melt)
inoculation<-rep("inoc6",times=nrow(water2inoc6_melt))
water<-rep("water2",times=nrow(water2inoc6_melt))
water2inoc6_melt<-cbind(water2inoc6_melt,inoculation,water)

water3inoc1_tax_sum_family = summarize_taxonomy(water3inoc1, level = 5, report_higher_tax = FALSE)
water3inoc1_tax_sum_family$family <-row.names(water3inoc1_tax_sum_family)
water3inoc1_melt<- melt(water3inoc1_tax_sum_family, id.var="family")
nrow(water3inoc1_melt)
inoculation<-rep("inoc1",times=nrow(water3inoc1_melt))
water<-rep("water3",times=nrow(water3inoc1_melt))
water3inoc1_melt<-cbind(water3inoc1_melt,inoculation,water)

water3inoc4_tax_sum_family = summarize_taxonomy(water3inoc4, level = 5, report_higher_tax = FALSE)
water3inoc4_tax_sum_family$family <-row.names(water3inoc4_tax_sum_family)
water3inoc4_melt<- melt(water3inoc4_tax_sum_family, id.var="family")
nrow(water3inoc4_melt)
inoculation<-rep("inoc4",times=nrow(water3inoc4_melt))
water<-rep("water3",times=nrow(water3inoc4_melt))
water3inoc4_melt<-cbind(water3inoc4_melt,inoculation,water)

water3inoc5_tax_sum_family = summarize_taxonomy(water3inoc5, level = 5, report_higher_tax = FALSE)
water3inoc5_tax_sum_family$family <-row.names(water3inoc5_tax_sum_family)
water3inoc5_melt<- melt(water3inoc5_tax_sum_family, id.var="family")
nrow(water3inoc5_melt)
inoculation<-rep("inoc5",times=nrow(water3inoc5_melt))
water<-rep("water3",times=nrow(water3inoc5_melt))
water3inoc5_melt<-cbind(water3inoc5_melt,inoculation,water)

water3inoc6_tax_sum_family = summarize_taxonomy(water3inoc6, level = 5, report_higher_tax = FALSE)
water3inoc6_tax_sum_family$family <-row.names(water3inoc6_tax_sum_family)
water3inoc6_melt<- melt(water3inoc6_tax_sum_family, id.var="family")
nrow(water3inoc6_melt)
inoculation<-rep("inoc6",times=nrow(water3inoc6_melt))
water<-rep("water3",times=nrow(water3inoc6_melt))
water3inoc6_melt<-cbind(water3inoc6_melt,inoculation,water)

familyfinalbind<-do.call("rbind",list(water1inoc1_melt,water1inoc4_melt,water1inoc5_melt,water1inoc6_melt,water2inoc1_melt,water2inoc4_melt,water2inoc5_melt,water2inoc6_melt,water3inoc1_melt,water3inoc4_melt,water3inoc5_melt,water3inoc6_melt))

Shoots family graph

library(ggthemes)
shootsfamily<-ggplot(familyfinalbind, aes(x = inoculation, y = value, fill = family)) + 
  geom_bar(stat="identity",position = "fill") + 
  scale_y_continuous(labels = scales::percent) +
  scale_fill_manual(values = colorRampPalette(solarized_pal()(8))(90)) + 
  ggtitle("Shoots Family Graphs")+
  facet_grid(.~water,scales ="free",space="free")+
  theme(
    axis.text = element_text(color='black',size=10),
    axis.title.y= element_blank(),
    axis.title.x= element_blank(),
    axis.title = element_text(color='black',size=12),
    axis.ticks = element_line(color='black'),
    legend.title = element_text(size=18),
    panel.background = element_rect(fill=NA,color='black'),
    panel.grid = element_blank(),
    legend.key.size = unit(1, 'mm'),
    legend.text = element_text(color='black',size=4),
    plot.title=element_text(size=20,face="bold",vjust=2))

shootsfamily

ggsave("figures/shootsfamily.pdf", height=8, width=17)

#ggsave(filename = "shootsfamily.pdf",
#       plot = shootsfamily,
#       bg = "transparent",
#       width = 17, height = 8, units = "in",
#       dpi = 600)

Now we can make t1 roots by inoculation and water treatment

#let's refilter again just in case but include the control too
#Pair down the other data. We will have to hellinger transform this data too

inputstep5 = filter_data(input, 'TimePoint', keep_vals = 'T1')
## 438 samples remaining
roots = filter_data(inputstep5, 'Type', keep_vals = 'Root')
## 219 samples remaining
water1 = filter_data(roots, 'Water', keep_vals = '1')
## 66 samples remaining
water1inoc1 = filter_data(water1, 'Inoculation', keep_vals = '1')
## 14 samples remaining
water1inoc4 = filter_data(water1, 'Inoculation', keep_vals = '4')
## 9 samples remaining
water1inoc5 = filter_data(water1, 'Inoculation', keep_vals = '5')
## 10 samples remaining
water1inoc6 = filter_data(water1, 'Inoculation', keep_vals = '6')
## 10 samples remaining
water2 = filter_data(inputstep5, 'Water', keep_vals = '2')
## 152 samples remaining
water2inoc1 = filter_data(water2, 'Inoculation', keep_vals = '1')
## 26 samples remaining
water2inoc4 = filter_data(water2, 'Inoculation', keep_vals = '4')
## 25 samples remaining
water2inoc5 = filter_data(water2, 'Inoculation', keep_vals = '5')
## 26 samples remaining
water2inoc6 = filter_data(water2, 'Inoculation', keep_vals = '6')
## 22 samples remaining
water3 = filter_data(inputstep5, 'Water', keep_vals = '3')
## 153 samples remaining
water3inoc1 = filter_data(water3, 'Inoculation', keep_vals = '1')
## 25 samples remaining
water3inoc4 = filter_data(water3, 'Inoculation', keep_vals = '4')
## 27 samples remaining
water3inoc5 = filter_data(water3, 'Inoculation', keep_vals = '5')
## 21 samples remaining
water3inoc6 = filter_data(water3, 'Inoculation', keep_vals = '6')
## 26 samples remaining
#transformation
otuTAB<-water1inoc1$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water1inoc1$data_loaded<-t(hell)
otuTAB<-water1inoc4$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water1inoc4$data_loaded<-t(hell)
otuTAB<-water1inoc5$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water1inoc5$data_loaded<-t(hell)
otuTAB<-water1inoc6$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water1inoc6$data_loaded<-t(hell)

otuTAB<-water2inoc1$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water2inoc1$data_loaded<-t(hell)
otuTAB<-water2inoc4$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water2inoc4$data_loaded<-t(hell)
otuTAB<-water2inoc5$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water2inoc5$data_loaded<-t(hell)
otuTAB<-water2inoc6$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water2inoc6$data_loaded<-t(hell)

otuTAB<-water3inoc1$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water3inoc1$data_loaded<-t(hell)
otuTAB<-water3inoc4$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water3inoc4$data_loaded<-t(hell)
otuTAB<-water3inoc5$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water3inoc5$data_loaded<-t(hell)
otuTAB<-water3inoc6$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water3inoc6$data_loaded<-t(hell)

We will need to make a large dataframe here. View after melting to see how many columns to make. This will be family for shoots

library(reshape2)
water1inoc1_tax_sum_family = summarize_taxonomy(water1inoc1, level = 5, report_higher_tax = FALSE)
water1inoc1_tax_sum_family$family <-row.names(water1inoc1_tax_sum_family)
water1inoc1_melt<- melt(water1inoc1_tax_sum_family, id.var="family")
nrow(water1inoc1_melt)
inoculation<-rep("inoc1",times=nrow(water1inoc1_melt))
water<-rep("water1",times=nrow(water1inoc1_melt))
water1inoc1_melt<-cbind(water1inoc1_melt,inoculation,water)

water1inoc4_tax_sum_family = summarize_taxonomy(water1inoc4, level = 5, report_higher_tax = FALSE)
water1inoc4_tax_sum_family$family <-row.names(water1inoc4_tax_sum_family)
water1inoc4_melt<- melt(water1inoc4_tax_sum_family, id.var="family")
nrow(water1inoc4_melt)
inoculation<-rep("inoc4",times=nrow(water1inoc4_melt))
water<-rep("water1",times=nrow(water1inoc4_melt))
water1inoc4_melt<-cbind(water1inoc4_melt,inoculation,water)

water1inoc5_tax_sum_family = summarize_taxonomy(water1inoc5, level = 5, report_higher_tax = FALSE)
water1inoc5_tax_sum_family$family <-row.names(water1inoc5_tax_sum_family)
water1inoc5_melt<- melt(water1inoc5_tax_sum_family, id.var="family")
nrow(water1inoc5_melt)
inoculation<-rep("inoc5",times=nrow(water1inoc5_melt))
water<-rep("water1",times=nrow(water1inoc5_melt))
water1inoc5_melt<-cbind(water1inoc5_melt,inoculation,water)

water1inoc6_tax_sum_family = summarize_taxonomy(water1inoc6, level = 5, report_higher_tax = FALSE)
water1inoc6_tax_sum_family$family <-row.names(water1inoc6_tax_sum_family)
water1inoc6_melt<- melt(water1inoc6_tax_sum_family, id.var="family")
nrow(water1inoc6_melt)
inoculation<-rep("inoc6",times=nrow(water1inoc6_melt))
water<-rep("water1",times=nrow(water1inoc6_melt))
water1inoc6_melt<-cbind(water1inoc6_melt,inoculation,water)

water2inoc1_tax_sum_family = summarize_taxonomy(water2inoc1, level = 5, report_higher_tax = FALSE)
water2inoc1_tax_sum_family$family <-row.names(water2inoc1_tax_sum_family)
water2inoc1_melt<- melt(water2inoc1_tax_sum_family, id.var="family")
nrow(water2inoc1_melt)
inoculation<-rep("inoc1",times=nrow(water2inoc1_melt))
water<-rep("water2",times=nrow(water2inoc1_melt))
water2inoc1_melt<-cbind(water2inoc1_melt,inoculation,water)

water2inoc4_tax_sum_family = summarize_taxonomy(water2inoc4, level = 5, report_higher_tax = FALSE)
water2inoc4_tax_sum_family$family <-row.names(water2inoc4_tax_sum_family)
water2inoc4_melt<- melt(water2inoc4_tax_sum_family, id.var="family")
nrow(water2inoc4_melt)
inoculation<-rep("inoc4",times=nrow(water2inoc4_melt))
water<-rep("water2",times=nrow(water2inoc4_melt))
water2inoc4_melt<-cbind(water2inoc4_melt,inoculation,water)

water2inoc5_tax_sum_family = summarize_taxonomy(water2inoc5, level = 5, report_higher_tax = FALSE)
water2inoc5_tax_sum_family$family <-row.names(water2inoc5_tax_sum_family)
water2inoc5_melt<- melt(water2inoc5_tax_sum_family, id.var="family")
nrow(water2inoc5_melt)
inoculation<-rep("inoc5",times=nrow(water2inoc5_melt))
water<-rep("water2",times=nrow(water2inoc5_melt))
water2inoc5_melt<-cbind(water2inoc5_melt,inoculation,water)

water2inoc6_tax_sum_family = summarize_taxonomy(water2inoc6, level = 5, report_higher_tax = FALSE)
water2inoc6_tax_sum_family$family <-row.names(water2inoc6_tax_sum_family)
water2inoc6_melt<- melt(water2inoc6_tax_sum_family, id.var="family")
nrow(water2inoc6_melt)
inoculation<-rep("inoc6",times=nrow(water2inoc6_melt))
water<-rep("water2",times=nrow(water2inoc6_melt))
water2inoc6_melt<-cbind(water2inoc6_melt,inoculation,water)

water3inoc1_tax_sum_family = summarize_taxonomy(water3inoc1, level = 5, report_higher_tax = FALSE)
water3inoc1_tax_sum_family$family <-row.names(water3inoc1_tax_sum_family)
water3inoc1_melt<- melt(water3inoc1_tax_sum_family, id.var="family")
nrow(water3inoc1_melt)
inoculation<-rep("inoc1",times=nrow(water3inoc1_melt))
water<-rep("water3",times=nrow(water3inoc1_melt))
water3inoc1_melt<-cbind(water3inoc1_melt,inoculation,water)

water3inoc4_tax_sum_family = summarize_taxonomy(water3inoc4, level = 5, report_higher_tax = FALSE)
water3inoc4_tax_sum_family$family <-row.names(water3inoc4_tax_sum_family)
water3inoc4_melt<- melt(water3inoc4_tax_sum_family, id.var="family")
nrow(water3inoc4_melt)
inoculation<-rep("inoc4",times=nrow(water3inoc4_melt))
water<-rep("water3",times=nrow(water3inoc4_melt))
water3inoc4_melt<-cbind(water3inoc4_melt,inoculation,water)

water3inoc5_tax_sum_family = summarize_taxonomy(water3inoc5, level = 5, report_higher_tax = FALSE)
water3inoc5_tax_sum_family$family <-row.names(water3inoc5_tax_sum_family)
water3inoc5_melt<- melt(water3inoc5_tax_sum_family, id.var="family")
nrow(water3inoc5_melt)
inoculation<-rep("inoc5",times=nrow(water3inoc5_melt))
water<-rep("water3",times=nrow(water3inoc5_melt))
water3inoc5_melt<-cbind(water3inoc5_melt,inoculation,water)

water3inoc6_tax_sum_family = summarize_taxonomy(water3inoc6, level = 5, report_higher_tax = FALSE)
water3inoc6_tax_sum_family$family <-row.names(water3inoc6_tax_sum_family)
water3inoc6_melt<- melt(water3inoc6_tax_sum_family, id.var="family")
nrow(water3inoc6_melt)
inoculation<-rep("inoc6",times=nrow(water3inoc6_melt))
water<-rep("water3",times=nrow(water3inoc6_melt))
water3inoc6_melt<-cbind(water3inoc6_melt,inoculation,water)

familyrootfinalbind<-do.call("rbind",list(water1inoc1_melt,water1inoc4_melt,water1inoc5_melt,water1inoc6_melt,water2inoc1_melt,water2inoc4_melt,water2inoc5_melt,water2inoc6_melt,water3inoc1_melt,water3inoc4_melt,water3inoc5_melt,water3inoc6_melt))

Roots family graph

library(ggthemes)
Rootsfamily<-ggplot(familyrootfinalbind, aes(x = inoculation, y = value, fill = family)) + 
  geom_bar(stat="identity",position = "fill") + 
  scale_y_continuous(labels = scales::percent) +
  scale_fill_manual(values = colorRampPalette(solarized_pal()(8))(90)) + 
  ggtitle("Roots Family Graphs")+
  facet_grid(.~water,scales ="free",space="free")+
  theme(
    axis.text = element_text(color='black',size=10),
    axis.title.y= element_blank(),
    axis.title.x= element_blank(),
    axis.title = element_text(color='black',size=12),
    axis.ticks = element_line(color='black'),
    legend.title = element_text(size=18),
    panel.background = element_rect(fill=NA,color='black'),
    panel.grid = element_blank(),
    legend.key.size = unit(1, 'mm'),
    legend.text = element_text(color='black',size=4),
    plot.title=element_text(size=20,face="bold",vjust=2))

Rootsfamily

ggsave("figures/Rootsfamily.pdf", height=8, width=17)

#ggsave(filename = "Rootsfamily.pdf",
#       plot = Rootsfamily,
#       bg = "transparent",
#       width = 17, height = 8, units = "in",
#       dpi = 600)

Now we can make t0 shoots by inoculation and water treatment

#let's refilter again just in case but include the control too
#Pair down the other data. We will have to hellinger transform this data too

inputstep5 = filter_data(input, 'TimePoint', keep_vals = 'T0')
## 96 samples remaining
shoots = filter_data(inputstep5, 'Type', keep_vals = 'Shoot')
## 96 samples remaining
water1inoc1 = filter_data(shoots, 'Inoculation', keep_vals = '1')
## 14 samples remaining
water1inoc4 = filter_data(shoots, 'Inoculation', keep_vals = '4')
## 19 samples remaining
water1inoc5 = filter_data(shoots, 'Inoculation', keep_vals = '5')
## 11 samples remaining
water1inoc6 = filter_data(shoots, 'Inoculation', keep_vals = '6')
## 18 samples remaining
#transformation
otuTAB<-water1inoc1$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water1inoc1$data_loaded<-t(hell)
otuTAB<-water1inoc4$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water1inoc4$data_loaded<-t(hell)
otuTAB<-water1inoc5$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water1inoc5$data_loaded<-t(hell)
otuTAB<-water1inoc6$data_loaded
otuTAB <- as.data.frame (otuTAB)
otuTABtranspose<-t(otuTAB)
hell<-hellinger(otuTABtranspose)
water1inoc6$data_loaded<-t(hell)

We will need to make a large dataframe here. View after melting to see how many columns to make. This will be family for shoots t0

library(reshape2)
water1inoc1_tax_sum_family = summarize_taxonomy(water1inoc1, level = 5, report_higher_tax = FALSE)
water1inoc1_tax_sum_family$family <-row.names(water1inoc1_tax_sum_family)
water1inoc1_melt<- melt(water1inoc1_tax_sum_family, id.var="family")
nrow(water1inoc1_melt)
inoculation<-rep("inoc1",times=nrow(water1inoc1_melt))
water<-rep("water1",times=nrow(water1inoc1_melt))
water1inoc1_melt<-cbind(water1inoc1_melt,inoculation,water)

water1inoc4_tax_sum_family = summarize_taxonomy(water1inoc4, level = 5, report_higher_tax = FALSE)
water1inoc4_tax_sum_family$family <-row.names(water1inoc4_tax_sum_family)
water1inoc4_melt<- melt(water1inoc4_tax_sum_family, id.var="family")
nrow(water1inoc4_melt)
inoculation<-rep("inoc4",times=nrow(water1inoc4_melt))
water<-rep("water1",times=nrow(water1inoc4_melt))
water1inoc4_melt<-cbind(water1inoc4_melt,inoculation,water)

water1inoc5_tax_sum_family = summarize_taxonomy(water1inoc5, level = 5, report_higher_tax = FALSE)
water1inoc5_tax_sum_family$family <-row.names(water1inoc5_tax_sum_family)
water1inoc5_melt<- melt(water1inoc5_tax_sum_family, id.var="family")
nrow(water1inoc5_melt)
inoculation<-rep("inoc5",times=nrow(water1inoc5_melt))
water<-rep("water1",times=nrow(water1inoc5_melt))
water1inoc5_melt<-cbind(water1inoc5_melt,inoculation,water)

water1inoc6_tax_sum_family = summarize_taxonomy(water1inoc6, level = 5, report_higher_tax = FALSE)
water1inoc6_tax_sum_family$family <-row.names(water1inoc6_tax_sum_family)
water1inoc6_melt<- melt(water1inoc6_tax_sum_family, id.var="family")
nrow(water1inoc6_melt)
inoculation<-rep("inoc6",times=nrow(water1inoc6_melt))
water<-rep("water1",times=nrow(water1inoc6_melt))
water1inoc6_melt<-cbind(water1inoc6_melt,inoculation,water)

familyshoott0finalbind<-do.call("rbind",list(water1inoc1_melt,water1inoc4_melt,water1inoc5_melt,water1inoc6_melt))

Shoots T0 family graph

library(ggthemes)
Shootst0family<-ggplot(familyshoott0finalbind, aes(x = inoculation, y = value, fill = family)) + 
  geom_bar(stat="identity",position = "fill") + 
  scale_y_continuous(labels = scales::percent) +
  scale_fill_manual(values = colorRampPalette(solarized_pal()(8))(90)) + 
  ggtitle("Shoots T0 Family Graphs")+
  facet_grid(.~water,scales ="free",space="free")+
  theme(
    axis.text = element_text(color='black',size=10),
    axis.title.y= element_blank(),
    axis.title.x= element_blank(),
    axis.title = element_text(color='black',size=12),
    axis.ticks = element_line(color='black'),
    legend.title = element_text(size=18),
    panel.background = element_rect(fill=NA,color='black'),
    panel.grid = element_blank(),
    legend.key.size = unit(1, 'mm'),
    legend.text = element_text(color='black',size=4),
    plot.title=element_text(size=20,face="bold",vjust=2))

Shootst0family

ggsave("figures/Shootst0family.pdf", height=8, width=10)

#ggsave(filename = "Shootst0family.pdf",
#       plot = Shootst0family,
#       bg = "transparent",
#       width = 10, height = 8, units = "in",
#       dpi = 600)

Let’s start with the raw data. The venn diagram we want is split into the three water groups. Then we need original inoculum, leaves post-inoc post stress, leaves post-inoc pre stress, roots post inoc post stress

Now we need to pair down the data. Then do nrows. Then merge by the rows and then do nrows. Then we can make the euler diagrams

First let’s split into inoculation 1, 2 and 3

Inoculation 1

input <- load_taxa_table("data/ASV_table_postfiltering.txt", "data/map_loaded_strawberries.txt")
## 538 samples loaded
#inoc1
inputinoc1only = filter_data(input, 'Inoculation', keep_vals = '1')
## 92 samples remaining
#leaves post-inoc post stress
inputinoc1onlyshoot = filter_data(inputinoc1only, 'Type', keep_vals = 'Shoot')
## 52 samples remaining
inoc1shootpostinocpoststress = filter_data(inputinoc1onlyshoot, 'SampleType', keep_vals = 'post_inoc_post_stress')
## 38 samples remaining
i1spips<-as.data.frame(inoc1shootpostinocpoststress$data_loaded)
i1spips$ASV <-row.names(i1spips)
#roots post-inoc post-stress
inputinoc1onlyroot = filter_data(inputinoc1only, 'Type', keep_vals = 'Root')
## 40 samples remaining
inoc1rootpostinocpoststress = filter_data(inputinoc1onlyroot, 'SampleType', keep_vals = 'post_inoc_post_stress')
## 40 samples remaining
i1rpips<-as.data.frame(inoc1rootpostinocpoststress$data_loaded)
i1rpips$ASV <-row.names(i1rpips)
#leaves post-inoc pre-stress
inoc1shootpostinocprestress = filter_data(inputinoc1onlyshoot, 'SampleType', keep_vals = 'post_inoc_pre_stress')
## 14 samples remaining
i1spiprs<-as.data.frame(inoc1shootpostinocprestress$data_loaded)
i1spiprs$ASV <-row.names(i1spiprs)
#Then let's grab original inoculum. We will need to grab the original data frame again.
inputraw <- load_taxa_table("data/ASV_table_mctoolsr.txt", "data/strawberries_raw_full_data.txt")
## 626 samples loaded
slurryonly = filter_data(inputraw, 'SampleType', keep_vals = 'slurry')
## 10 samples remaining
slurryonlyinoc1 = filter_data(slurryonly, 'Type', keep_vals = 'Inoculum 1')
## 2 samples remaining
slurryinoc1<-as.data.frame(slurryonlyinoc1$data_loaded)
slurryinoc1$ASV <-row.names(slurryinoc1)

Let’s count the number of rows:

nrow(i1spips)
## [1] 308
nrow(i1rpips)
## [1] 537
nrow(i1spiprs)
## [1] 89
nrow(slurryinoc1)
## [1] 20

Let’s see how these all overlap:

i1spips_i1rpips <- inner_join(i1spips, i1rpips, 
                       c("ASV"))
nrow(i1spips_i1rpips)
i1spips_i1spiprs <- inner_join(i1spips, i1spiprs, 
                       c("ASV"))
nrow(i1spips_i1spiprs)
i1spips_slurry <- inner_join(i1spips, slurryinoc1, 
                       c("ASV"))
nrow(i1spips_slurry)
i1rpips_i1spiprs <- inner_join(i1spiprs, i1rpips, 
                       c("ASV"))
nrow(i1rpips_i1spiprs)
i1rpips_slurry <- inner_join(slurryinoc1, i1rpips, 
                       c("ASV"))
nrow(i1rpips_slurry)
i1spiprs_slurry <- inner_join(slurryinoc1, i1spiprs, 
                       c("ASV"))
nrow(i1spiprs_slurry)
all <- inner_join(i1spiprs_slurry, i1spips_i1rpips, 
                       c("ASV"))
nrow(all)
ABC <- inner_join(i1spips_i1rpips, i1spiprs, 
                       c("ASV"))
nrow(ABC)
ABD <- inner_join(i1spips_i1rpips, slurryinoc1, 
                       c("ASV"))
nrow(ABD)
BCD <- inner_join(i1spiprs_slurry, i1rpips, 
                       c("ASV"))
nrow(BCD)

i1spips = 308 = A i1rpips = 537 = B i1spiprs = 89 = C slurry = 20 = D

i1spips & i1rpips = 211 = A&B i1spips & i1spiprs = 63 = A&C i1spips & slurry = 13 = A&D i1rpips & i1spiprs = 64 = B&C i1rpips & slurry = 12 = B&D i1spiprs & slurry = 11 = C&D i1spips & i1rpips & i1spiprs & slurry = 10 = A&B&C&D i1spips & i1rpips & i1spiprs = = A&B&C = 58 i1spips & i1rpips & slurry = = A&B&D = 12 i1rpips & i1spiprs & slurry = 10 = B&C&D

Inoculation 1 graph

# use eulerr

inoc1 <-c("Shoot Post-Inoc Post-Stress" = 308, "Root Post-Inoc Post-Stress" = 537, "Shoot Post-Inoc Pre-Stress" = 89, "Slurry" = 20, 
                    "Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress" = 211, "Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress" = 63, "Shoot Post-Inoc Post-Stress&Slurry" = 13, "Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress" = 64,"Root Post-Inoc Post-Stress&Slurry" = 12,
                    "Shoot Post-Inoc Pre-Stress&Slurry" = 11, "Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry" = 10, "Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress" = 58, "Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Slurry" = 12,
                    "Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry" = 10)
fitinoc1 <- euler(inoc1,shape="ellipse")

fitinoc1
##                                                                                          original
## Shoot Post-Inoc Post-Stress                                                                   308
## Root Post-Inoc Post-Stress                                                                    537
## Shoot Post-Inoc Pre-Stress                                                                     89
## Slurry                                                                                         20
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress                                        211
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                         63
## Shoot Post-Inoc Post-Stress&Slurry                                                             13
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                          64
## Root Post-Inoc Post-Stress&Slurry                                                              12
## Shoot Post-Inoc Pre-Stress&Slurry                                                              11
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress              58
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Slurry                                  12
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                   0
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                   10
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry       10
##                                                                                          fitted
## Shoot Post-Inoc Post-Stress                                                                 308
## Root Post-Inoc Post-Stress                                                                  537
## Shoot Post-Inoc Pre-Stress                                                                   89
## Slurry                                                                                        0
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress                                      211
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                       63
## Shoot Post-Inoc Post-Stress&Slurry                                                            0
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                        64
## Root Post-Inoc Post-Stress&Slurry                                                             0
## Shoot Post-Inoc Pre-Stress&Slurry                                                            11
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress            58
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Slurry                                 0
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                 0
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                 10
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry     10
##                                                                                          residuals
## Shoot Post-Inoc Post-Stress                                                                      0
## Root Post-Inoc Post-Stress                                                                       0
## Shoot Post-Inoc Pre-Stress                                                                       0
## Slurry                                                                                          20
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress                                           0
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                           0
## Shoot Post-Inoc Post-Stress&Slurry                                                              13
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                            0
## Root Post-Inoc Post-Stress&Slurry                                                               12
## Shoot Post-Inoc Pre-Stress&Slurry                                                                0
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                0
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Slurry                                   12
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                    0
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                     0
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry         0
##                                                                                          regionError
## Shoot Post-Inoc Post-Stress                                                                    0.009
## Root Post-Inoc Post-Stress                                                                     0.016
## Shoot Post-Inoc Pre-Stress                                                                     0.003
## Slurry                                                                                         0.014
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress                                         0.006
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                         0.002
## Shoot Post-Inoc Post-Stress&Slurry                                                             0.009
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                          0.002
## Root Post-Inoc Post-Stress&Slurry                                                              0.008
## Shoot Post-Inoc Pre-Stress&Slurry                                                              0.000
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress              0.002
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Slurry                                  0.008
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                  0.000
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                   0.000
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry       0.000
## 
## diagError: 0.016 
## stress:    0.002
ggsave("figures/inoc1venn.pdf", height=8, width=8)

Inoculation 4

input <- load_taxa_table("data/ASV_table_postfiltering.txt", "data/map_loaded_strawberries.txt")
## 538 samples loaded
#inoc4
inputinoc4only = filter_data(input, 'Inoculation', keep_vals = '4')
## 89 samples remaining
#leaves post-inoc post stress
inputinoc4onlyshoot = filter_data(inputinoc4only, 'Type', keep_vals = 'Shoot')
## 54 samples remaining
inoc4shootpostinocpoststress = filter_data(inputinoc4onlyshoot, 'SampleType', keep_vals = 'post_inoc_post_stress')
## 35 samples remaining
i4spips<-as.data.frame(inoc4shootpostinocpoststress$data_loaded)
i4spips$ASV <-row.names(i4spips)
#roots post-inoc post-stress
inputinoc4onlyroot = filter_data(inputinoc4only, 'Type', keep_vals = 'Root')
## 35 samples remaining
inoc4rootpostinocpoststress = filter_data(inputinoc4onlyroot, 'SampleType', keep_vals = 'post_inoc_post_stress')
## 35 samples remaining
i4rpips<-as.data.frame(inoc4rootpostinocpoststress$data_loaded)
i4rpips$ASV <-row.names(i4rpips)
#leaves post-inoc pre-stress
inoc4shootpostinocprestress = filter_data(inputinoc4onlyshoot, 'SampleType', keep_vals = 'post_inoc_pre_stress')
## 19 samples remaining
i4spiprs<-as.data.frame(inoc4shootpostinocprestress$data_loaded)
i4spiprs$ASV <-row.names(i4spiprs)
#Then let's grab original inoculum. We will need to grab the original data frame again.
inputraw <- load_taxa_table("data/ASV_table_mctoolsr.txt", "data/strawberries_raw_full_data.txt")
## 626 samples loaded
slurryonly = filter_data(inputraw, 'SampleType', keep_vals = 'slurry')
## 10 samples remaining
slurryonlyinoc4 = filter_data(slurryonly, 'Type', keep_vals = 'Inoculum 4')
## 2 samples remaining
slurryinoc4<-as.data.frame(slurryonlyinoc4$data_loaded)
slurryinoc4$ASV <-row.names(slurryinoc4)

Let’s count the number of rows:

nrow(i4spips)
## [1] 290
nrow(i4rpips)
## [1] 519
nrow(i4spiprs)
## [1] 108
nrow(slurryinoc4)
## [1] 9

Let’s see how these all overlap:

i4spips_i4rpips <- inner_join(i4spips, i4rpips, 
                       c("ASV"))
nrow(i4spips_i4rpips)
i4spips_i4spiprs <- inner_join(i4spips, i4spiprs, 
                       c("ASV"))
nrow(i4spips_i4spiprs)
i4spips_slurry <- inner_join(i4spips, slurryinoc4, 
                       c("ASV"))
nrow(i4spips_slurry)
i4rpips_i4spiprs <- inner_join(i4spiprs, i4rpips, 
                       c("ASV"))
nrow(i4rpips_i4spiprs)
i4rpips_slurry <- inner_join(slurryinoc4, i4rpips, 
                       c("ASV"))
nrow(i4rpips_slurry)
i4spiprs_slurry <- inner_join(slurryinoc4, i4spiprs, 
                       c("ASV"))
nrow(i4spiprs_slurry)
all <- inner_join(i4spiprs_slurry, i4spips_i4rpips, 
                       c("ASV"))
nrow(all)
ABC <- inner_join(i4spips_i4rpips, i4spiprs, 
                       c("ASV"))
nrow(ABC)
ABD <- inner_join(i4spips_i4rpips, slurryinoc4, 
                       c("ASV"))
nrow(ABD)
BCD <- inner_join(i4spiprs_slurry, i4rpips, 
                       c("ASV"))
nrow(BCD)

i4spips = 290 = A i4rpips = 519 = B i4spiprs = 108 = C slurry = 9 = D

i4spips & i4rpips = 187 = A&B i4spips & i4spiprs = 67 = A&C i4spips & slurry = 5 = A&D i4rpips & i4spiprs = 71 = B&C i4rpips & slurry = 5 = B&D i4spiprs & slurry = 2 = C&D i4spips & i4rpips & i4spiprs & slurry = 2 = A&B&C&D i4spips & i4rpips & i4spiprs = = A&B&C = 60 i4spips & i4rpips & slurry = = A&B&D = 4 i4rpips & i4spiprs & slurry = 2 = B&C&D

Inoculation 4 graph

inoc4 <-c("Shoot Post-Inoc Post-Stress" = 290, "Root Post-Inoc Post-Stress" = 519, "Shoot Post-Inoc Pre-Stress" = 108, "Slurry" = 9, 
                    "Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress" = 187, "Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress" = 67, "Shoot Post-Inoc Post-Stress&Slurry" = 5, "Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress" = 71,"Root Post-Inoc Post-Stress&Slurry" = 5,
                    "Shoot Post-Inoc Pre-Stress&Slurry" = 2, "Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry" = 2, "Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress" = 60, "Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Slurry" = 4,
                    "Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry" = 2)

fitinoc4 <- euler(inoc4,shape="ellipse")

fitinoc4
##                                                                                          original
## Shoot Post-Inoc Post-Stress                                                                   290
## Root Post-Inoc Post-Stress                                                                    519
## Shoot Post-Inoc Pre-Stress                                                                    108
## Slurry                                                                                          9
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress                                        187
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                         67
## Shoot Post-Inoc Post-Stress&Slurry                                                              5
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                          71
## Root Post-Inoc Post-Stress&Slurry                                                               5
## Shoot Post-Inoc Pre-Stress&Slurry                                                               2
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress              60
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Slurry                                   4
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                   0
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                    2
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry        2
##                                                                                          fitted
## Shoot Post-Inoc Post-Stress                                                                 290
## Root Post-Inoc Post-Stress                                                                  519
## Shoot Post-Inoc Pre-Stress                                                                  108
## Slurry                                                                                        0
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress                                      187
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                       67
## Shoot Post-Inoc Post-Stress&Slurry                                                            0
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                        71
## Root Post-Inoc Post-Stress&Slurry                                                             0
## Shoot Post-Inoc Pre-Stress&Slurry                                                             2
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress            60
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Slurry                                 0
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                 0
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                  2
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry      2
##                                                                                          residuals
## Shoot Post-Inoc Post-Stress                                                                      0
## Root Post-Inoc Post-Stress                                                                       0
## Shoot Post-Inoc Pre-Stress                                                                       0
## Slurry                                                                                           9
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress                                           0
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                           0
## Shoot Post-Inoc Post-Stress&Slurry                                                               5
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                            0
## Root Post-Inoc Post-Stress&Slurry                                                                5
## Shoot Post-Inoc Pre-Stress&Slurry                                                                0
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                0
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Slurry                                    4
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                    0
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                     0
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry         0
##                                                                                          regionError
## Shoot Post-Inoc Post-Stress                                                                    0.004
## Root Post-Inoc Post-Stress                                                                     0.007
## Shoot Post-Inoc Pre-Stress                                                                     0.001
## Slurry                                                                                         0.007
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress                                         0.002
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                         0.001
## Shoot Post-Inoc Post-Stress&Slurry                                                             0.004
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                          0.001
## Root Post-Inoc Post-Stress&Slurry                                                              0.004
## Shoot Post-Inoc Pre-Stress&Slurry                                                              0.000
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress              0.001
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Slurry                                  0.003
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                  0.000
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                   0.000
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry       0.000
## 
## diagError: 0.007 
## stress:    0
ggsave("figures/inoc4venn.pdf", height=8, width=8)

Inoculation 5

input <- load_taxa_table("data/ASV_table_postfiltering.txt", "data/map_loaded_strawberries.txt")
## 538 samples loaded
#inoc5
inputinoc5only = filter_data(input, 'Inoculation', keep_vals = '5')
## 79 samples remaining
#leaves post-inoc post stress
inputinoc5onlyshoot = filter_data(inputinoc5only, 'Type', keep_vals = 'Shoot')
## 46 samples remaining
inoc5shootpostinocpoststress = filter_data(inputinoc5onlyshoot, 'SampleType', keep_vals = 'post_inoc_post_stress')
## 35 samples remaining
i5spips<-as.data.frame(inoc5shootpostinocpoststress$data_loaded)
i5spips$ASV <-row.names(i5spips)
#roots post-inoc post-stress
inputinoc5onlyroot = filter_data(inputinoc5only, 'Type', keep_vals = 'Root')
## 33 samples remaining
inoc5rootpostinocpoststress = filter_data(inputinoc5onlyroot, 'SampleType', keep_vals = 'post_inoc_post_stress')
## 33 samples remaining
i5rpips<-as.data.frame(inoc5rootpostinocpoststress$data_loaded)
i5rpips$ASV <-row.names(i5rpips)
#leaves post-inoc pre-stress
inoc5shootpostinocprestress = filter_data(inputinoc5onlyshoot, 'SampleType', keep_vals = 'post_inoc_pre_stress')
## 11 samples remaining
i5spiprs<-as.data.frame(inoc5shootpostinocprestress$data_loaded)
i5spiprs$ASV <-row.names(i5spiprs)
#Then let's grab original inoculum. We will need to grab the original data frame again.
inputraw <- load_taxa_table("data/ASV_table_mctoolsr.txt", "data/strawberries_raw_full_data.txt")
## 626 samples loaded
slurryonly = filter_data(inputraw, 'SampleType', keep_vals = 'slurry')
## 10 samples remaining
slurryonlyinoc5 = filter_data(slurryonly, 'Type', keep_vals = 'Inoculum 5')
## 2 samples remaining
slurryinoc5<-as.data.frame(slurryonlyinoc5$data_loaded)
slurryinoc5$ASV <-row.names(slurryinoc5)

Let’s count the number of rows:

nrow(i5spips)
## [1] 174
nrow(i5rpips)
## [1] 263
nrow(i5spiprs)
## [1] 64
nrow(slurryinoc5)
## [1] 50

Let’s see how these all overlap:

i5spips_i5rpips <- inner_join(i5spips, i5rpips, 
                       c("ASV"))
nrow(i5spips_i5rpips)
i5spips_i5spiprs <- inner_join(i5spips, i5spiprs, 
                       c("ASV"))
nrow(i5spips_i5spiprs)
i5spips_slurry <- inner_join(i5spips, slurryinoc5, 
                       c("ASV"))
nrow(i5spips_slurry)
i5rpips_i5spiprs <- inner_join(i5spiprs, i5rpips, 
                       c("ASV"))
nrow(i5rpips_i5spiprs)
i5rpips_slurry <- inner_join(slurryinoc5, i5rpips, 
                       c("ASV"))
nrow(i5rpips_slurry)
i5spiprs_slurry <- inner_join(slurryinoc5, i5spiprs, 
                       c("ASV"))
nrow(i5spiprs_slurry)
all <- inner_join(i5spiprs_slurry, i5spips_i5rpips, 
                       c("ASV"))
nrow(all)
ABC <- inner_join(i5spips_i5rpips, i5spiprs, 
                       c("ASV"))
nrow(ABC)
ABD <- inner_join(i5spips_i5rpips, slurryinoc5, 
                       c("ASV"))
nrow(ABD)
BCD <- inner_join(i5spiprs_slurry, i5rpips, 
                       c("ASV"))
nrow(BCD)

i5spips = 174 = A i5rpips = 263 = B i5spiprs = 64 = C slurry = 50 = D

i5spips & i5rpips = 115 = A&B i5spips & i5spiprs = 43 = A&C i5spips & slurry = 12 = A&D i5rpips & i5spiprs = 49 = B&C i5rpips & slurry = 12 = B&D i5spiprs & slurry = 10 = C&D i5spips & i5rpips & i5spiprs & slurry = 10 = A&B&C&D i5spips & i5rpips & i5spiprs = A&B&C = 39 i5spips & i5rpips & slurry = A&B&D = 12 i5rpips & i5spiprs & slurry = 10 = B&C&D

Inoculation 5 graph

inoc5 <-c("Shoot Post-Inoc Post-Stress" = 174, "Root Post-Inoc Post-Stress" = 263, "Shoot Post-Inoc Pre-Stress" = 64, "Slurry" = 50, 
                    "Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress" = 115, "Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress" = 43, "Shoot Post-Inoc Post-Stress&Slurry" = 12, "Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress" = 49,"Root Post-Inoc Post-Stress&Slurry" = 12,
                    "Shoot Post-Inoc Pre-Stress&Slurry" = 10, "Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry" = 10, "Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress" = 39, "Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Slurry" = 12,
                    "Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry" = 10)
fitinoc5 <- euler(inoc5,shape="ellipse")

fitinoc5
##                                                                                          original
## Shoot Post-Inoc Post-Stress                                                                   174
## Root Post-Inoc Post-Stress                                                                    263
## Shoot Post-Inoc Pre-Stress                                                                     64
## Slurry                                                                                         50
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress                                        115
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                         43
## Shoot Post-Inoc Post-Stress&Slurry                                                             12
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                          49
## Root Post-Inoc Post-Stress&Slurry                                                              12
## Shoot Post-Inoc Pre-Stress&Slurry                                                              10
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress              39
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Slurry                                  12
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                   0
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                   10
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry       10
##                                                                                          fitted
## Shoot Post-Inoc Post-Stress                                                                 174
## Root Post-Inoc Post-Stress                                                                  263
## Shoot Post-Inoc Pre-Stress                                                                   64
## Slurry                                                                                       50
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress                                      115
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                       43
## Shoot Post-Inoc Post-Stress&Slurry                                                            0
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                        49
## Root Post-Inoc Post-Stress&Slurry                                                            12
## Shoot Post-Inoc Pre-Stress&Slurry                                                            10
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress            39
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Slurry                                 0
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                 0
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                 10
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry      0
##                                                                                          residuals
## Shoot Post-Inoc Post-Stress                                                                      0
## Root Post-Inoc Post-Stress                                                                       0
## Shoot Post-Inoc Pre-Stress                                                                       0
## Slurry                                                                                           0
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress                                           0
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                           0
## Shoot Post-Inoc Post-Stress&Slurry                                                              12
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                            0
## Root Post-Inoc Post-Stress&Slurry                                                                0
## Shoot Post-Inoc Pre-Stress&Slurry                                                                0
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                0
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Slurry                                   12
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                    0
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                     0
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry        10
##                                                                                          regionError
## Shoot Post-Inoc Post-Stress                                                                    0.008
## Root Post-Inoc Post-Stress                                                                     0.012
## Shoot Post-Inoc Pre-Stress                                                                     0.003
## Slurry                                                                                         0.002
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress                                         0.005
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                         0.002
## Shoot Post-Inoc Post-Stress&Slurry                                                             0.014
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress                                          0.002
## Root Post-Inoc Post-Stress&Slurry                                                              0.001
## Shoot Post-Inoc Pre-Stress&Slurry                                                              0.000
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress              0.002
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Slurry                                  0.014
## Shoot Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                  0.000
## Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry                                   0.000
## Shoot Post-Inoc Post-Stress&Root Post-Inoc Post-Stress&Shoot Post-Inoc Pre-Stress&Slurry       0.012
## 
## diagError: 0.014 
## stress:    0.003
ggsave("figures/inoc5venn.pdf", height=8, width=8)